本文介绍了无法读取Set-Cookie响应标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的api调用,我正在尝试从响应标头中读取Set-Cookie
Here is my api call, I am trying to read Set-Cookie from response header
return $http(config).then(function (response) { console.log(response.headers('Set-Cookie')); // undefined console.log($cookies.ovrcMfa); // undefined return response.data; });,响应标头为:
Access-Control-Allow-Credentials: true Access-Control-Allow-Headers: Content-Type, Authorization, Set-Cookie, X-Requested-With, X-Session-Id, X-App-version, X-Target-Client, X-Origin-Domain, X-Dev-Mode Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS Access-Control-Allow-Origin: * Access-Control-Expose-Headers: Set-Cookie Set-Cookie : ovrc-mfa=IHfpt06ogxzLQFpwySE7vaJYg7whQ0sF; Max-Age=31536000; Path=/; Expires=Thu, 16 Jan 2020 09:30:47 GMT在这里,我想读取Set-Cookie值,即ovrc-mfa
Here I want to read Set-Cookie value ie ovrc-mfa
推荐答案Set-Cookie是禁止的响应标头名称.您无法使用浏览器端的JavaScript读取它.
Set-Cookie is a forbidden response header name. You cannot read it using browser-side JavaScript.
如果您需要将该信息传递给JavaScript,则需要让服务器使用其他某种机制(例如,不同的标头或响应主体的一部分).
If you need to pass that information to your JavaScript, then you need to have the server use some other mechanism (such as a different header or part of the response body).
更多推荐
无法读取Set
发布评论