我正在localhost:3000上运行一个Range4客户端,它正在与WEB本地主机:5000通信。我的问题是,当服务器指示浏览器存储cookie时,我无法理解浏览器为什么拒绝存储cookie。
客户端请求头
Request URL:https://local.dev:5000/user/list?page=1&column=Email&listOrder=2
Request Method:POST
Status Code:200 OK
Remote Address:127.0.0.1:5000
Referrer Policy:no-referrer-when-downgrade
Accept:application/json
Accept-Encoding:gzip, deflate, br
Accept-Language:en-NZ,en-GB;q=0.8,en-US;q=0.6,en;q=0.4
Cache-Control:no-cache
Connection:keep-alive
Content-Length:0
Content-Type:application/json
DNT:1
Host:local.dev:5000
Origin:https://localhost:3000
Pragma:no-cache
Referer:https://localhost:3000/user服务器响应头:
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:https://localhost:3000
Cache-Control:no-cache
Content-Type:application/json; charset=utf-8
credentials:include
Date:Tue, 09 May 2017 08:22:25 GMT
Expires:-1
Pragma:no-cache
Server:Kestrel
Set-Cookie: <cookiename>=<somedata>; expires=Tue, 09 May 2017 09:22:23 GMT; domain=local.dev; path=/; secure; httponly
Transfer-Encoding:chunked
Vary:Origin
withCredentials:true如您所见,CORS也已启用。HTTPS用于传输。也尝试过而不设置过期日期。cookie的域设置为local.dev。我也尝试了/和localhost。
之后,Chrome的调试视图不显示cookie。只是一些默认的角曲奇。因此,我假设由于某种原因而忽略了set-cookie头。

帮助!
发布于 2017-05-09 09:52:14
对于跨域AJAX请求,需要显式地指定应与请求一起发送cookie,并在响应中接受cookie。
这是使用withCredentials对象的XMLHttpRequest标志完成的。
在角,您可以将它设置为$http服务的一个选项,也可以参见AngularJS withCredentials
https://stackoverflow.com/questions/43865038
复制相似问题