2016-02-05 182 views
0

我有一個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

回答

1

很好,因爲它似乎在應用程序中的某個地方做一個HTTP POST調用。 你該請求發送給

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

,因爲它似乎是沒有服務器偵聽 - 或者至少不是一個POST請求。可能你必須在你的代碼中找到http請求,並檢查你是否使用了正確的url請求

+0

的網址是好的,我定義的路徑在我routeconfig,我能夠用GET來獲取值請求,我不明白爲什麼POST請求不被允許 – Giu