小编fam*_*mbo的帖子

Nodejs使用'Access-Control-Allow-Origin'快速解决CORS问题

我正在尝试使用Angular 1,Nodejs和Express创建单页面应用程序.我正在使用Angular的$ http post功能发布请求,我将请求中的标头值传递给API端点.

我在Chrome中遇到错误消息:

XMLHttpRequest cannot load 
http://localhost:7878/EIAMIDSupportREST/EIAMIDSupport/updateEIAMID. 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:3000' is therefore not allowed access. The credentials 
mode of requests initiated by the XMLHttpRequest is controlled by the 
withCredentials attribute.
Run Code Online (Sandbox Code Playgroud)

有了这个请求正文:

HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET,PUT,POST,PATCH,DELETE
Access-Control-Allow-Headers: Content-Type
Allow: POST
Content-Type: text/html; charset=utf-8
Content-Length: 4
Date: Tue, 23 May 2017 23:32:15 GMT
Connection: …
Run Code Online (Sandbox Code Playgroud)

javascript http-headers node.js cors express

1
推荐指数
3
解决办法
5749
查看次数

标签 统计

cors ×1

express ×1

http-headers ×1

javascript ×1

node.js ×1