3

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?

ditoslav
  • 4,563
  • 10
  • 47
  • 79

1 Answers1

2

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

xhr.withCredentials = true

See also

On the server

Access-Control-Allow-Credentials: true

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

Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • I'm sending from localhost:5000 to localhost:5000 – ditoslav Jan 11 '16 at 15:02
  • Not sure what you mean by "sending from localhost:5000 to localhost:5000". Do you load the page from the same port where you make the HttpRequests to? – Günter Zöchbauer Jan 11 '16 at 15:05
  • Yes. My flask backend is serving the static files for the website and responding to the requests from the same port – ditoslav Jan 11 '16 at 15:09
  • 1
    Actually, I don't know. Anyway, Angular isn't involved. This only a server<->browser issue. You could try a `POST` request. If it's a CORS issue the request will fail with a message containing "preflight". See also http://stackoverflow.com/questions/14801021/what-can-cause-a-cookie-not-to-be-set-on-the-client – Günter Zöchbauer Jan 11 '16 at 15:15