任何人都可以告诉我为什么我的’WWW-Authenticate’标题在响应中为空,尽管我能够在Chrome开发工具中看到字符串化的’WWW-Authenticate’标题对象?
在服务器端,我正在执行以下操作来设置我的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-Authenticate:{“token”:“encryptedToken”,“message”:“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 })
提前谢谢你的帮助!