angulartypescriptangular-http

Set Cookie in Request Headers Angular2


I am new to angular2. My server(spring) responds authentication with a set-cookie value in its response headers.

How to set that cookie to the request headers for the next API calls?

I searched a lot, but I cannot find a suitable solution.


Solution

  • Cookies are automatically attached to every call you make after it is saved for your domain. You are doing something else wrong. In case you want to create automatic mechanism for attaching auth data to REST calls, refere to this tutorial that creates custom HttpInterceptor:

    https://medium.com/aviabird/http-interceptor-angular2-way-e57dc2842462