Can anyone tell me why my 'WWW-Authenticate' header is null in the response, eventhough I am able see the stringified 'WWW-Authenticate' header object in the Chrome dev tools?
On the server side I am doing the following to set my WWW-Authenticate header as well as set the proper headers for CORS:
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:8080');
res.setHeader('Access-Control-Expose-Headers', 'WWW-Authenticate');
res.setHeader('WWW-Authenticate', JSON.stringify({
"token": "encryptedToken",
"message": "encryptedMessage"
}));
I believe that I am setting the header correctly on the server side, because When I look at the Chrome Dev tools, I see the following under "Response Headers" for the request that is being made.
Response Headers
Access-Control-Allow-Origin:http://localhost:8080
Access-Control-Expose-Headers:WWW-Authenticate
Connection:keep-alive
Date:Fri, 15 May 2015 13:48:29 GMT
ETag:W/"f7-1470611871"
WWW-Authenticate: {"token":"encryptedToken","message":"encryptedMessage"}
X-Powered-By:Express
HOWEVER, when I try to access the "WWW-Authenticate" header from within the response, I get NULL.
$http.get("http://localhost:4242/days")
.then(function (response) {
var AuthHeader = response.headers('WWW-Authenticate');
console.log (AuthHeader); // returns null
})
Thank you for your help in advance!