CNode

soket.io提示跨域问题

问答
Ddolphinfine发布于8 年前最后回复8 年前4 回复4684 浏览0 收藏

今天在公司官网,控制台发现这个: image.png

文字如下: Failed to load https://www.xxx.com:7001/socket.io/?EIO=3&transport=polling&t=1520584510239-0: 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 'https://www.xx.com' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

这是之前的人做的,我只是维护,soket这部分从来没有动过,以前也没发现问题。网上搜了一下,相关信息不多,感觉都没在点子上。请问这种情况是怎么回事?怎么修复?

查看回复

回复 (4)

D
dolphinfine#1·8 年前
引用 leemove后台按照这个设置一下就行了...设置下cors

@leemove 搜索了一下‘Access-Control-Allow-Origin’,没有搜到这个字段,可能根本没设置。我们是node+jade做的网站

H
htoooth#2·8 年前

@dolphinfine 使用 cors 中间件,express 的

L
leemove#3·8 年前

后台按照这个设置一下就行了...设置下cors

D
dolphinfine#4·8 年前
引用 htoooth@dolphinfine 使用 cors 中间件,express 的

@htoooth 好的谢谢我先去了解一下这个用法。

参与回复
登录后即可参与回复。登录