请求服务器报错 Access-Control-Allow-Origin

今天遇到一个问题,发送请求能够成功了,返回的数据也能在 network 中看见,但是报错:

Access to XMLHttpRequest at 'http://192.168.200.112:8080/lottery/getIsWinLottery?Id=966&succ7F0D92C70492DCD' from origin 'http://192.168.200.196' has been blocked by CORS policy: 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'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

请求服务器报错 Access-Control-Allow-Origin

请求状态码为200,在 network 中也能看到返回的数据,但是控制台没有打印信息。

搜了半天发现了解决方案:

withCredentials: false, // 允许携带cookie

其他方案都需要后端调配置。

 

Failed to load http://pre.api.jmxy.mockuai.c...: 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://pre.promotion.jmxy.moc...' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

上一篇:Dump Mscash/Mscache


下一篇:linux下git怎么保存账号密码