为了账号安全,请及时绑定邮箱和手机立即绑定

混合app中客户端允许发送 cookie后,服务器跨域必须设置域名怎么办?

混合app中客户端允许发送 cookie后,服务器跨域必须设置域名怎么办?

江户川乱折腾 2019-03-13 17:15:50
客户端代码:let xhr = new XMLHttpRequest();xhr.open('post' , url , true);xhr.withCredentials = true;xhr.send(null);服务端:header('Access-Control-Allow-Origin: *');header('Access-Control-Allow-Credentials: true');客户端报错:Access to XMLHttpRequest at 'http://t.com/index.php' from origin 'null' has been blocked by CORS policy: 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.请求头也变成没有完整信息的请求头了:请问,混合 app 开发方式下,如何允许客户端携带 cookie ??
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 419 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号