小编Pra*_*ash的帖子

无法读取 Set-Cookie 响应标头

这是我的 api 调用,我试图从响应头中读取 Set-Cookie

 return $http(config).then(function (response) {
      console.log(response.headers('Set-Cookie')); // undefined
      console.log($cookies.ovrcMfa); // undefined
    return response.data;
  });
Run Code Online (Sandbox Code Playgroud)

和响应头是:

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
Run Code Online (Sandbox Code Playgroud)

这里我想读取 Set-Cookie 值,即 ovrc-mfa

javascript cookies http angularjs

3
推荐指数
1
解决办法
3278
查看次数

标签 统计

angularjs ×1

cookies ×1

http ×1

javascript ×1