XmlHttpRequest getAllResponseHeaders() not returning all the headers
Just ran into this. It's because you're doing a CORS request and you're not exposing the Location header.
You need to add a Access-Control-Expose-Headers
to your preflight CORS response in Express:
res.header('Access-Control-Expose-Headers', 'Content-Type, Location');res.send(200);
That will solve the issue.
according to the following
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers
The Access-Control-Expose-Headers response header indicates which headers can be exposed as part of the response by listing their names.
By default, only the 7 CORS-safelisted response headers are exposed:
Cache-ControlContent-LanguageContent-LengthContent-TypeExpiresLast-ModifiedPragma
So this will work perfectly for all headers to be accessible and exposed
res.header('Access-Control-Expose-Headers', '*');