相关疑难解决方法(0)

Set-Cookie标头未显示在Google Chrome中

问题

我正在运行带有设置cookie的Post端点的Spring Boot服务器。当从我的角度应用程序向端点发出请求时,我在Chrome的开发控制台的响应标题中看不到Set-Cookie标题。为什么Set-Cookie标头不显示?

调查摘要

使用curl时,Set-Cookie响应标头确实会显示在响应标头中,Safari上也存在Set-Cookie,并且它会显示在chrome net-export日志中。

环境

  • 我在Mac上的/ etc / hosts文件中为xxx.com添加了一个指向我的本地主机的条目。
  • 我正在使用ng serve --host 0.0.0.0 --disable-host-check命令托管角度UI http://example.com:4200
  • 我正在运行Spring Boot服务器 http://example.com:8080
  • 感兴趣的发布终点位于 http://example.com:8080/accounts/v1/user/authenticate
  • 使用最新版的chrome Version 73.0.3683.103 (Official Build) (64-bit)

尝试调试

苹果浏览器

Set-Cookie标头在Safari开发人员控制台的响应标头中可见。

Chrome开发者控制台

转到devconsole->网络->身份验证请求。我查看了请求和响应头,而Set-Cookie不在那儿。

请求头

Accept: application/json, text/plain, */*
Content-Type: application/json
Origin: http://example.com:4200
Referer: http://example.com:4200/
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Run Code Online (Sandbox Code Playgroud)

响应头

Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://example.com:4200
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Connection: keep-alive
Content-Type: application/json;charset=UTF-8
Date: Wed, 17 Apr …
Run Code Online (Sandbox Code Playgroud)

google-chrome http spring-boot angular

8
推荐指数
1
解决办法
908
查看次数

标签 统计

angular ×1

google-chrome ×1

http ×1

spring-boot ×1