我正在连接的后端开发人员向我保证,当他发送 cookie 时set-cookie
header 表示浏览器应自动保存 cookie 并通过后续请求将其发送回来。
Angular 2 是否会阻止发送 cookie?
由于后端和前端都在本地主机上运行,它们位于不同的端口上是否会阻止 cookie 与请求一起发送?
使用不同的端口是 CORS 请求。
放
在客户端上
xhr.withCredentials = true
也可以看看
- Angular 2 Http 请求不发送凭据 https://stackoverflow.com/questions/32905399/angular-2-http-request-does-not-send-credentials
- Angular2 替换 $httpProvider.defaults.withCredentials https://stackoverflow.com/questions/34184049/angular2-replacement-of-httpprovider-defaults-withcredentials
在服务器上
Access-Control-Allow-Credentials: true
http://www.html5rocks.com/en/tutorials/cors/?redirect_from_locale=de http://www.html5rocks.com/en/tutorials/cors/?redirect_from_locale=de
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)