Does Angular 2 application block cookies from being stored by default?

☆樱花仙子☆ 提交于 2019-12-12 12:48:02

问题


A developer of a backend to which I am connecting is assuring me that when he sends a cookie in set-cookie header that the browser should automatically save the cookie and send it back with following requests.

Does Angular 2 block cookies from being sent?

Since backend and frontend are both running on localhost, does them being on different ports block cookies from being sent with the requests?


回答1:


With a different port it's a CORS request. Set on the client

xhr.withCredentials = true

See also

  • Angular 2 Http request does not send credentials
  • Angular2 replacement of $httpProvider.defaults.withCredentials

On the server

Access-Control-Allow-Credentials: true

http://www.html5rocks.com/en/tutorials/cors/?redirect_from_locale=de



来源:https://stackoverflow.com/questions/34709964/does-angular-2-application-block-cookies-from-being-stored-by-default

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!