The value of the ‘Access-Control-Allow-Origin‘ header in the response 关于后端配置允许跨域后前端请求依然失败得不到响应的问题

1.引言

        作者在进行联系session分布式登录的时候,遇到了一个问题,就是明明我的后端进行配置了允许跨域,但是前端依然请求失败,无法收到请求,并报出如下错误。

         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

2.问题引入

2.1前端的axios的配置

        由于需要进行使用cookie等请求凭证相关的东西,在默认情况下,axios进行发送请求到后端的时候是不提供请求凭证的(cookie、HTTP认证及客户端SSL证明等),所以需要进行设置axios.defaults.withCredentials = true

2.2后端配置跨域

        由于后端是为了保证安全的,前端配置跨域可能是一种曲线救国的

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值