Reloading the page gives wrong GET request with AngularJS HTML5 mode

前端 未结 24 2905
慢半拍i
慢半拍i 2020-11-22 01:39

I want to enable HTML5 mode for my app. I have put the following code for the configuration, as shown here:

return app.config([\'$routeProvider\',\'$location         


        
24条回答
  •  迷失自我
    2020-11-22 01:58

    Finally I got a way to to solve this issue by server side as it's more like an issue with AngularJs itself I am using 1.5 Angularjs and I got same issue on reload the page. But after adding below code in my server.js file it is save my day but it's not a proper solution or not a good way .

    app.use(function(req, res, next){
      var d = res.status(404);
         if(d){
            res.sendfile('index.html');
         }
    });
    

提交回复
热议问题