Angular OPTIONS请求401

时间:2015-11-10 15:04:17

标签: javascript angularjs cors

我正在编写一个与Java Spring服务器通信的Angular(1.4.7)应用程序。我没有服务器端访问权。

当尝试从服务器获取数据时,我应该发送自定义标头“X-AUTH-TOKEN”。在我的Angular控制器中,我有以下代码:

UINavigationBar

已设置ASP.NET 5ret=iimPlayCode("TAG POS=1 TYPE=BUTTON ATTR=DATA-LOG-CLICK:add-button CONTENT=EVENT:MOUSEOVER"); if (ret == false) // not found else // found 个变量。当此代码运行时,它会抛出此错误:

$http.defaults.headers.common['X-AUTH-TOKEN'] = authToken; var req = { method: "GET", url: dataEndpoint } $http(req).then(function(response) { console.log(response) }) Angular似乎正在发送一个OPTIONS请求,根据CORS规范我读过这个请求是正确的。

我已经与可以访问服务器端的团队进行了交谈,他们说它能够处理CORS并且确实设置了authToken

Server request settings

回复标题:

dataEndpoint

请求标题:

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access. The response had HTTP status code 401.

看起来Access-Control-Allow-Origin实际上并未设置。不知道我错过了什么。如果我能更清楚地了解任何信息,请告诉我!

0 个答案:

没有答案
相关问题