Angular $http CORS 405 方法不允许

Angular $http CORS 405 Method Not Allowed

我正尝试使用 angular $http.get 模块从 api 系统获取 GET 但是 :

api 端点系统只接受 GET 方法,不能使用 OPTION 方法

请求 headers :

Host: www.example.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Access-Control-Request-Method: GET
Access-Control-Request-Headers: x-device-type,x-software-version,x-unit-measurement
Origin: http://localhost:3000
Connection: keep-alive

回应headers:

状态码:405 方法不允许

Access-Control-Allow-Headers: Content-Type, Accept, origin, referring-domain, X-UNIT-MEASUREMENT, X-AUTH-TOKEN, X-DEVICE-TYPE, X-SOFTWARE-VERSION
Access-Control-Request-Method: GET, POST, PUT, DELETE, OPTIONS
Allow: GET
Cache-Control: private,no-transform
Content-Length: 1565
Content-Type: text/html; charset=UTF-8
Date: Thu, 14 Apr 2016 11:41:13 GMT
Server: Microsoft-IIS/8.5
X-API-VERSION: 1.40.1.0
X-INSTANCE-ID: ALL
X-Powered-By: ASP.NET
access-control-allow-credentials: true
access-control-allow-origin: *
p3p: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"

我刚试过这个东西:

1: 设置默认 Content-Type 甚至 text/plain 和其他类型 [不工作]

$httpProvider.defaults.headers.common['Content-Type'] ='application/x-www-form-urlencoded; charset=UTF-8';

因为我在 运行 我的应用程序中使用 Atom Electron shell,所以我的快速解决方案是使用 --disable-web-security 在浏览器中禁用 CORS 保护。