angularjs POST 405方法不允许

问题描述:

我有一个angularjs项目,其中包含一个github oauth。我使用satellizer plugin来处理oauth协议。angularjs POST 405方法不允许

每次我尝试连接,我得到这个错误:

enter image description here

,这里是我的路由配置(它使用巴贝尔ES6):

export default function RouteConfig($routeProvider, $locationProvider) { 

$routeProvider 
    .when('/', { 
     templateUrl: './modules/default/default.html', 
     controller: 'DefaultController', 
     controllerAs: 'default' 
    }) 
    .when('/auth/:provider',{ 
     controller: 'OAuthController', 
     templateUrl: './modules/auth/auth.html', 
    }) 
    .otherwise({ 
     redirectTo: '/' 
    }); 
} 

我测试用邮差的应用,所有GET请求均正常工作,但每个POST请求返回405.

我使用live-server托管我的angularJS应用程序。我读过这个问题可能与服务器有关。我该如何解决这个问题?

我也使用npm来处理包。

**编辑:**我simplehttpserver试过这里是我的了:

enter image description here

很好,因为它似乎在应用程序中的某个地方做一个HTTP POST调用。 你该请求发送给

http://localhost:8080/src/auth/callback 

,因为它似乎是没有服务器侦听 - 或者至少不是一个POST请求。可能你必须在你的代码中找到http请求,并检查你是否使用了正确的url请求

+0

的网址是好的,我定义的路径在我routeconfig,我能够用GET来获取值请求,我不明白为什么POST请求不被允许 – Giu

我终于想通了。 AngularJS无法处理POST请求,这是服务器的责任,我忘记了为服务器启动并添加代码。

对于那些谁都会有同样的问题比我的例子是在这里:

https://github.com/sahat/satellizer/tree/master/examples