任何人都可以告诉我为什么我的'WWW-Authenticate'标头在响应中为null,尽管我能够看到字符串的'WWW-Authenticate'标头对象在Chrome开发工具?
在服务器端,我做以下设置我的WWW-Authenticate头以及设置正确的标头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"
}));
我相信我正确设置标题中的服务器上因为当我查看Chrome开发工具时,我在正在制作的请求的“响应头”下看到以下内容。
响应头
访问控制允许来源:http://localhost:8080
访问控制展露报头:WWW验证
连接:保持活跃
日期 :2015年5月15日星期五13:48:29 GMT
ETag:W /“f7-1470611871”
WWW验证:{ “令牌”: “encryptedToken”, “消息”: “encryptedMessage”}
X供电,通过:快速
然而,当我尝试访问响应中的“WWW-Authenticate”头,我得到NULL。
$http.get("http://localhost:4242/days")
.then(function (response) {
var AuthHeader = response.headers('WWW-Authenticate');
console.log (AuthHeader); // returns null
})
非常感谢您的帮助!
尝试记录整个响应对象 – charlietfl
响应对象--- {data:Array [7],status:200,headers:function,config:Object,statusText:“OK”} –
不,我想访问'WWW-Authenticate'标题对象(仍然字符串化),但响应。即使我可以在开发工具中看到对象,标题函数仍会返回null。 –