Mark
Mark

Reputation: 2432

Bug in Angular HttpClient or using it incorrectly?

I'm trying to access the HttpHeaders from an HttpErrorResponse but I cannot see all the headers, am I using the HttpClient incorrectly or is this an Angular bug: Sample demonstrating the problem

I can see in the developer tools that there should be the following header WWW-Authenticate:Bearer realm="spotify" however it is not present.

Upvotes: 0

Views: 212

Answers (1)

user4676340
user4676340

Reputation:

I encountered a similar issue with the eTag header : this is a Cross Origin issue.

From what I remember, CORS return only a couple of simple headers, such as Cache-Control, Content-Language, Content-Type, Expires, Last-Modified, etc.

If you want to return a specific header, you have to add another header, Access-Control-Expose-Headers, containing a list of the headers you want to return with it. So, in your case, Access-Control-Expose-Headers = 'WWW-Authenticate'.

You also obvioulsy need to change your backend to return the same header to Angular.

Hope this helps !

Upvotes: 1

Related Questions