soket.io提示跨域问题
发布于 6 年前 作者 dolphinfine 3509 次浏览 来自 问答

今天在公司官网,控制台发现这个: 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 回复

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

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

@dolphinfine 使用 cors 中间件,express 的

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

回到顶部