我在客户端使用
选项请求头
选项响应头
获取请求头信息
获取响应头信息
credentials: 'include'
和mode: 'cors'
。在服务器上,我看到access-control-allow-credentials: true
和access-control-allow-origin: https://dev.com:9443
头部。但是我没有看到我的cookie
头部,而且我找不到为什么它没有发送的原因。如果需要更多详细信息,请告诉我。fetch(url, {
method: 'get',
credentials: 'include',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
}
});
选项请求头
:authority: prod.fakedomain.com
:method: OPTIONS
:path: /Search
:scheme: https
accept: */*
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9,fr;q=0.8,la;q=0.7
access-control-request-headers: content-type
access-control-request-method: GET
cache-control: no-cache
dnt: 1
origin: https://dev.com:9443
pragma: no-cache
referer: https://dev.com:9443/
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
选项响应头
access-control-allow-credentials: true
access-control-allow-headers: content-type
access-control-allow-methods: GET,HEAD,POST
access-control-allow-origin: https://dev.com:9443
access-control-max-age: 1800
allow: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH
content-length: 0
date: Mon, 04 Feb 2019 03:45:06 GMT
status: 200
vary: Origin
x-application-context: application:8080
获取请求头信息
:authority: prod.fakedomain.com
:method: GET
:path: /Search
:scheme: https
accept: */*
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9,fr;q=0.8,la;q=0.7
cache-control: no-cache
content-type: application/json
dnt: 1
origin: https://dev.com:9443
pragma: no-cache
referer: https://dev.com:9443/
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
获取响应头信息
access-control-allow-credentials: true
access-control-allow-origin: https://dev.com:9443
content-encoding: gzip
content-type: application/json;charset=UTF-8
date: Mon, 04 Feb 2019 03:45:07 GMT
status: 200
vary: Origin,Accept-Encoding
x-application-context: application:8080
prod.fakedomain.com
域设置任何 cookie。您的浏览器将仅发送该域已经在先前从prod.fakedomain.com
收到 Set-Cookie 响应头的某些响应中通过设置在浏览器的 cookie 存储中的 cookie。正如 @KamilKiełczewski 所示,该服务器似乎没有发送任何 Set-Cookie 响应头,因此看起来您从未在浏览器中设置任何 cookie。 - sideshowbarkerdev.com
的 cookie,但没有设置prod.fakedomain.com
的。我想让服务器(prod.fakedomain.com
)看到我的dev.com
cookie。如果没有prod.fakedomain.com
域名,那么这些 cookie 是否不会被发送? - anthony-dandrea