【发布时间】:2021-10-22 10:34:08
【问题描述】:
我正在尝试创建一个身份验证页面,该页面将通过 cookie 返回可在不同子域上使用的 JWT。这是我尝试实现的场景:
- 用户转到
authenticate.staging.example.com - 该页面将向
admin.api.staging.example.com发出 HTTP 请求(withCredentials: true)并返回这些标头:
Set-Cookie: jwt=myToken; Domain=.staging.example.com; SameSite=None; Secure
Access-Control-Allow-Headers: 'Accept, Content-Type'
Access-Control-Allow-Origin: 'https://authenticate.staging.example.com'
Access-Control-Allow-Methods: 'GET,POST,PATCH,PUT,DELETE,OPTIONS'
Access-Control-Allow-Credentials: 'true'
- 当用户转到
admin.staging.example.com或docs.staging.example.com时,会为所有请求(index.html等)发送JWT cookie
目前,我收到了 cookie,但当我转到 admin.staging.example.com 或 docs.staging.example.com 时它没有发送。如果该解决方案仅适用于最新的 Chrome,则没有问题。
感谢您的帮助
【问题讨论】:
标签: google-chrome cookies cross-domain subdomain session-cookies