响应标头中的Set-Cookie无效

时间:2017-09-19 16:10:58

标签: ruby-on-rails angular http cookies

我的后端(Ruby On Rails)运行在端口号为3000的登录端点(http://localhost:3000/login).I也有角度服务器在端口4200上运行。因为我正在点击登录端点并且成功登录后,响应是使用 Set-cookie 选项发回(设置了身份验证令牌)。但是它未在浏览器中设置.Below是我收到的响应标头:

Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:*
Access-Control-Allow-Methods:POST, GET, OPTIONS
Access-Control-Allow-Origin:http://localhost:4200
Access-Control-Max-Age:1728000
Cache-Control:max-age=0, private, must-revalidate
Content-Type:application/json; charset=utf-8
ETag:W/"9dae161444bc908fd3289f4ed0fb15ed"
Set-Cookie:auth_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJleHAiOjE1MDU4NDM0Nzh9.0E22wlacZWvmazpdJPLC4oRq3QM-8DX-npQu3w-U8Vs; path=/
Transfer-Encoding:chunked
Vary:Origin
X-Request-Id:267cfe1f-e60c-40b5-9a7b-4801d358cfd4
X-Runtime:0.273751
Request Headers
view source

如果我使用Postman点击那个API,那么cookie就会毫无问题地保存。

0 个答案:

没有答案