无法读取Set

编程入门 行业动态 更新时间:2024-10-26 14:27:58
本文介绍了无法读取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

本文发布于:2023-10-29 10:34:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539459.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Set

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!