-1

I'm having a problem with my Angular 8 application running in Edge (while all other browsers everything is working fine).

While making a login request, over the response header I receive back some values (token, correlationid, refresh token) but when I try to catch them in my application they return null, this is quite strange to me.

I've been checking and I have no CORS policy error or warning, even in the network tab I can clearly see that the login HTTP call returns 200 OK and those headers are present.

What is even more strange is that one of those values is indeed returned but the others are not, because of this my login flow fails since I can't validate all data has been properly returned.

Does anyone know why this may be happening? I've read that you shouldn't include underscore symbols which is also not my case.

Here's an image attached of what I'm getting

enter image description here

Here's how I'm trying to get the headers response values:

return this.http.post('MYENDPOINT/login', null, { headers: headers, observe: 'response' })
  .pipe(
    tap(res => {
      console.log('getting from response headers for key hcs-token: ', res.headers.get('hcs-token));
      console.log('getting from response headers for key HCS-TOKEN: ', res.headers.get('HCS-TOKEN));
      console.log('getting from response headers for key hcs-refresh-token: ', res.headers.get('hcs-refresh-token'));
      console.log('getting from response headers for key HCS-REFRESH-TOKEN: ', res.headers.get('HCS-REFRESH-TOKEN'));
      console.log('getting from response headers for key hcs-correlation-id: ', res.headers.get('hcs-correlation-id'));
      console.log('getting from response headers for key HCS-CORRELATION-ID: ', res.headers.get('HCS-CORRELATION-ID'));
    //some extra logic....

    }));
}
TylerH
  • 20,799
  • 66
  • 75
  • 101
Rodrigo Martinez
  • 913
  • 3
  • 13
  • 29
  • understand, EDGE or IE is not intelligent enough to correct syntax or flow issue while chrome and FF are, please share your code to help. – Abhinav Oct 03 '19 at 14:32
  • @user7417866 Updated with the code – Rodrigo Martinez Oct 03 '19 at 14:41
  • I'm in favor of Barry Pollard's answer. Besides, you could check if you have the right Nginx configuration. You could refer to [this thread](https://stackoverflow.com/questions/48117123/angular-5-response-header-is-missing-on-cors/48127124#48127124). You could refer to the comment below the accepted answer and the op has the same issue as yours. You could also check if you have tried [reading the full response](https://stackoverflow.com/questions/53309992/problem-with-retrieving-headers-in-angular-6/53310116#53310116). – Yu Zhou Oct 04 '19 at 03:04

1 Answers1

0

I would guess you are sending these in multiple headers and there is a known bug in IE/Edge for this which means you only get the first one.

So if your server is sending this:

Access-Control-Expose-Headers: hcs-token
Access-Control-Expose-Headers: hcs-refresh-token
Access-Control-Expose-Headers: hcs-correlation-id

then change it to this to resolve the issue for Edge (and still have it working in other browsers):

Access-Control-Expose-Headers: hcs-token, hcs-refresh-token, hcs-correlation-id

They should mean the same thing but Edge doesn’t see it like that due to the aforementioned bug.

I appreciate in your screenshot they are on one line but not sure what that screenshot is from and if it has automatically merged the multiple lines into one or if that is an accurate display of what is sent back? Might be best to use a command line tool to confirm? Or show your server side code.

Barry Pollard
  • 40,655
  • 7
  • 76
  • 92