CORS问题api有效,webpack没有

时间:2017-10-23 17:08:07

标签: java webpack cors

我有这些奇怪的问题。我正在使用API​​,启用了cors。 95%确定它以前工作正常。我的初始请求返回:

HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8
Server: Kestrel
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type,Authorization
Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS
Access-Control-Allow-Origin: http://localhost:8080
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcaGFsbGFnZC5XSUxMS0lFXFNvdXJjZVxSZXBvc1xXaWxsb3cgdjBcU2VjdXJpdHkgTW9kZWxcU2VjdXJpdHlNb2RlbFxzcmNcSWRlbnRpdHlTYW1wbGVBcHBsaWNhdGlvblxhY2NvdW50XGxvZ2lu?=
Persistent-Auth: true
X-Powered-By: ASP.NET
WWW-Authenticate: Negotiate oRswGaADCgEAoxIEEAEAAAAboUf9n7tg7AAAAAA=
Date: Mon, 23 Oct 2017 16:47:25 GMT

但是,第二个请求似乎来自webpack,其中包含Access-Control-Allow-Origin of'*':

HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin: *
Content-Type: text/event-stream;charset=utf-8
Cache-Control: no-cache, no-transform
Connection: keep-alive
X-Accel-Buffering: no
Date: Mon, 23 Oct 2017 16:47:27 GMT
Transfer-Encoding: chunked

这里发生了什么?

在控制台中,返回的错误是

Failed to load http://localhost:50841/account/login: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:8080' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

enter image description here

0 个答案:

没有答案