我正在连接的后端开发人员向我保证,当他在 set-cookie
header 中发送 cookie 时,浏览器应自动保存 cookie 并通过以下请求将其发回。
Angular 2 会阻止发送 cookie 吗?
由于后端和前端都在本地主机上运行,它们位于不同的端口是否会阻止 cookie 随请求一起发送?
最佳答案
对于不同的端口,它是一个 CORS 请求。 放 在客户端
xhr.withCredentials = true
另见
- Angular 2 Http request does not send credentials
- Angular2 replacement of $httpProvider.defaults.withCredentials
在服务器上
Access-Control-Allow-Credentials: true
http://www.html5rocks.com/en/tutorials/cors/?redirect_from_locale=de
关于session - Angular 2 应用程序是否默认阻止存储 cookie?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34709964/