node.js/angular.js - Cannot GET

前端 未结 4 1085
渐次进展
渐次进展 2021-02-07 11:22

I have the root route and it works fine. I also have a another route 127.0.0.1:3000/dashboard if I just type that url into the address bar I get this error:

Cannot GET /

4条回答
  •  独厮守ぢ
    2021-02-07 12:12

    This article might help:

    http://jjt.io/2013/11/16/angular-html5mode-using-yeoman-generator-angular/

    In a nutshell:

    npm install --save-dev connect-modrewrite
    

    Gruntfile:

    connect: {
      options: {
        // ...
        // Modrewrite rule, connect.static(path) for each path in target's base
        middleware: function (connect, options) {
          var optBase = (typeof options.base === 'string') ? [options.base] : options.base;
          return [require('connect-modrewrite')(['!(\\..+)$ / [L]'])].concat(
            optBase.map(function(path){ return connect.static(path); }));
        }
      }
    }
    

提交回复
热议问题