The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard

vue项目中axios请求数据的时候请求失败,出现跨域问题。

withCredentials 属性

CORS请求默认不发送Cookie和HTTP认证信息。但是有的后台要把Cookie发到服务器,要服务器同意,指定Access-Control-Allow-Credentials字段。

在axios的配置文件中配置withCredentials属性,默认带cookie给后台,

import Axios from 'axios';

Axios.defaults.withCredentials=true;


版权声明:本文为Zxiuping原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。