【Vue3】跨域问题 [The value of the ‘Access-Control-Allow-Origin‘ header in the response must not be the..]
场景vue 项目中 axios 请求数据的时候请求失败,出现跨域问题。报错信息The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard解决方法withCredentials 属性CORS 请求默认不发送 Cookie 和 HTTP 认证信息。如果要把 Cookie 发
·
场景
vue 项目中 axios 请求数据的时候请求失败,出现跨域问题。
报错信息
The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard
解决方法
withCredentials 属性
CORS 请求默认不发送 Cookie 和 HTTP 认证信息。如果要把 Cookie 发到服务器,一方面要服务器同意,指定 Access-Control-Allow-Credentials
字段。
出现这个报错信息很可能是你在前端设置了 withCredentials = true;
你可以去掉这个设置。
更多推荐
所有评论(0)