跨域问题花式踩坑(一)

在尝试前端自定义分享内容时遇到了跨域问题。经过研究发现,单纯使用星号*无法实现携带Cookie的跨域请求。解决方案在于CORS设置,包括Access-Control-Allow-Credentials字段的启用和Access-Control-Allow-Origin的精确指定。理解这一机制后,无论是阻止还是允许Cookie发送,都有了明确的操作指南。
摘要由CSDN通过智能技术生成

踩坑惨状

平时微信分享配置文件都是后台配置好放到服务器上,前端直接引用,后续因业务需要,更改为可自定义分享内容,通过前端接收后台配置,来实现自定义分享,此时单纯的我还不知道,一个大坑正在前方等待着我的到来……

Access to XMLHttpRequest at 'http://map.museum.chaoxing.com/beacon/config?urlhttp://file.museum.chaoxing.com/frontendTest/standard/index.html#/' from origin 'http://file.museum.chaoxing.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: 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.

踩坑分析:

一脸懵逼的我谷歌百度齐上阵,博客文档翻起来,终于功夫不负

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值