Set-cookie in response not set for Angular2 post request

I seems to be a CORS-related issue. Perhaps you could try to set the withCredentials attribute when executing the HTTP request.

This answer could help you to find out how to do that, especially the Cedric Exbrayat's answer:

  • angular2 xhrfields withcredentials true

Edit

You could extend the BrowserXhr:

@Injectable()
export class CustomBrowserXhr extends BrowserXhr {
  constructor() {}
  build(): any {
    let xhr = super.build();
    xhr.withCredentials = true;
    return <any>(xhr);
  }
}

and override the BrowserXhr provider with the extended:

bootstrap(AppComponent, [
  HTTP_PROVIDERS,
  provide(BrowserXhr, { useClass: CustomBrowserXhr })
]);

If you need more hints about CORS, you could have a look at this link: http://restlet.com/blog/2015/12/15/understanding-and-using-cors/.

Hope it helps you, Thierry


Indeed a CORS issue. From Angular2 RC2 on, you just need to

this.http.get('http://my.domain.com/request', { withCredentials: true })

I had the same problem but for me the cookie had a path to '/api/order'.. So only request to this path contained the cookie.. I altered the path to '/' and now everthig is fine..