Reloading the page gives wrong GET request with AngularJS HTML5 mode

前端 未结 24 3291
慢半拍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 02:13

    Solution for BrowserSync and Gulp.

    From https://github.com/BrowserSync/browser-sync/issues/204#issuecomment-102623643

    First install connect-history-api-fallback:

    npm --save-dev install connect-history-api-fallback
    

    Then add it to your gulpfile.js:

    var historyApiFallback = require('connect-history-api-fallback');
    
    gulp.task('serve', function() {
      browserSync.init({
        server: {
          baseDir: "app",
          middleware: [ historyApiFallback() ]
        }
      });
    });
    

提交回复
热议问题