我的网站a.domain公开了一个页面,其脚本执行 AJAX 查询(使用 fetch)到b.domain.
在第一次访问时a.domain,会向客户端发送一个带有以下参数的 cookie:
"httpOnly" : "true"
"secure" : "true"
"domain" : ".domain"
"sameSite" : tried Strict, Lax and None
b.domain具有以下响应标头:
"Access-Control-Allow-Origin" : "a.domain"
"Access-Control-Allow-Credentials : true
"Access-Control-Allow-Methods" : "GET, PUT, POST, DELETE, OPTIONS".
"Access-Control-Allow-Headers" : "Content-Type, Authorization, Content-Length, X-Requested-With, Credentials"
获取请求的标头是:
"Content-Type" : "application/json"
"Accept" : "application/json"
"Credentials" : "include"
cookie 可以很好地传输到a.domain或者如果我b.domain 直接访问,但不是在 AJAX 请求中。
编辑:无论相同站点参数的值如何,问题都是相同的。
有没有办法做到这一点 ?谢谢