微信 web 开发者工具,跨域调用资源的时候报错

发布于 6 年前作者 guiyingqian4913 次浏览最后编辑 6 年前来自 ask

错误一

XMLHttpRequest cannot load https://test.com/ws/target. The ‘Access-Control-Allow-Origin’ header contains multiple values ‘https://a.com, *’, but only one is allowed. Origin ‘https://a.com’ is therefore not allowed access.

错误二

XMLHttpRequest cannot load https://api.growingio.com/v2/zzzaaa/web/action?stm=1489659172277. A wildcard ‘*’ cannot be used in the ‘Access-Control-Allow-Origin’ header when the credentials flag is true. Origin ‘https://a.com’ is therefore not allowed access. The credentials mode of an XMLHttpRequest is controlled by the withCredentials attribute.

2 回复
qiang76
qiang761 楼6 年前

可否截图看下具体的报错信息

xiulanhou
xiulanhou2 楼4 年前

我也遇到一样的问题,提问的人已经写的很清楚了,控制台打印的就是那些。核心内容就是 A wildcard ‘*’ cannot be used in the ‘Access-Control-Allow-Origin’ header when the credentials flag is true.  

单问题是服务端根本没有返回 Access-Control-Allow-Origin ‘*’ ,而是直接返回的前端页面的域名