简体   繁体   English

不允许使用angularjs POST 405方法

[英]angularjs POST 405 method not allowed

I have an angularjs project that contains an oauth to github. 我有一个angularjs项目,其中包含对github的oauth。

I use the satellizer plugin to deal with the oauth protocol. 我使用satellizer插件来处理oauth协议。

Every time I try to connect I get this error: 每次尝试连接时,都会出现此错误:

在此处输入图片说明

Here is my route config (it's ES6 using Babel) : 这是我的路由配置(使用Babel的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: '/'
    });
}

I tested the app using Postman, all the GET requests work fine but every POST request returns a 405. 我使用Postman测试了该应用程序,所有GET请求均正常运行,但每个POST请求均返回405。

I use live-server to host my angularJS application. 我使用实时服务器托管我的angularJS应用程序。 I've read that the issue might be server-related. 我已经读过该问题可能与服务器有关。 How can I solve that ? 我该如何解决?

I also use npm to deal with the packages. 我还使用npm处理软件包。

**EDIT : ** I tried with simplehttpserver here is what I got: **编辑:**我尝试过使用simplehttpserver,这是我得到的:

在此处输入图片说明

well as it seems you do an http POST call somewhere in your application. 似乎您在应用程序中的某个位置进行了http POST调用。 and you send this request to 然后您将此请求发送给

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

as it seems there is no server listening - or at least not to a POST request. 似乎没有服务器在监听-或至少没有监听POST请求。 probably you will have to find the http request in your code and check whether you're using the correct url for your request 可能您将不得不在代码中找到http请求,并检查您是否为请求使用了正确的网址

I finally figured out. 我终于想通了。 AngularJS cannot deal with POST requests, it's the server responsibility to do that, I forgot to start and add code for the server. AngularJS无法处理POST请求,这是服务器的责任,我忘了为服务器启动和添加代码。

For those who will have the same issue than me, examples are here: 对于那些与我有同样问题的人,这里有一些例子:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM