AngularJS $routeProvider 和“404 Not Found”状态

AngularJS $routeProvider and "404 Not Found" status

我在我的应用程序中使用:

app.config(function ($routeProvider, $locationProvider, $httpProvider) {
$routeProvider
    .when('/', {
        templateUrl: '/index.html',
        controller: 'mainController'
    })
    .when('/login', {
        templateUrl: '/views/login.html',
        controller: 'LoginController'
    })
    .when('/user/list', {
        templateUrl: '/views/users/list.html',
        controller: 'userListController'
    }) 
    });
$locationProvider.html5Mode(true);
});

并且在 html 中有 <base href="/">。我在 google 应用程序引擎中使用此应用程序。在 app.yaml:

- url: /(user)/.*
  static_files: index.html
  upload: index.html

user 开头的链接一切正常。但是登录时出现404 Not Found错误。任何有关解决方案的建议将不胜感激。

删除 $locationProvider.. 它会产生许多冲突,如下所述:https://docs.angularjs.org/api/ng/provider/$locationProvider

Use the $locationProvider to configure how the application deep linking paths are stored.

接下来删除参数 $httpProvider,因为在您提供的代码中,您没有在 .config() 函数中的任何地方使用提供程序...希望这对您有所帮助。

编辑 App.yalm我觉得应该更像这样..

handlers:
- url: '/' 
    script: main.app

你能看一下 问题以获得更好的理解吗?希望这对您有所帮助!