Vue3跨域问题 [The value of the ‘Access-Control-Allow-Origin‘ header in the response must not be the..]

Posted 嘻嘻的妙妙屋

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 发到服务器,一方面要服务器同意,指定 Access-Control-Allow-Credentials 字段。

出现这个报错信息很可能是你在前端设置了 withCredentials = true; 你可以去掉这个设置。

以上是关于Vue3跨域问题 [The value of the ‘Access-Control-Allow-Origin‘ header in the response must not be the..]的主要内容,如果未能解决你的问题,请参考以下文章