我从Chrome获得了一个奇怪的行为,我最近没有得到。一周前,我的项目正在向我的REST api(Java spring)提出正确的CORS请求,一切都很好。但昨天,Chrome(59.0.3071.115)不再像过去那样发送JSESSIONID了。它现在发送一个io cookie。 io cookie似乎在某种程度上与WebSocket有关,我在任何代码中都没有使用它。
问题是,当我在Edge浏览器上尝试相同的代码时,一切都很好。 Edge确实发送了我的JSESSIONID cookie而没有" io" cookie已发送。
之前有人经历过这个吗?
以下是我的设置和两个浏览器上的请求示例。
设置: 操作系统:Windows 10 SPA:React,AXIOS(0.16.2) REST:Java,Spring启动,Tomcat(嵌入式)
AXIOS配置
function getNewAxiosInstance() {
//Init our instance
const ax = axios.create();
//Config defaults
ax.defaults.baseURL = rootUri;
ax.defaults.timeout = 1000;
ax.defaults.withCredentials = true;
return ax;
}
Chrome请求
Request URL:http://localhost:8080/api/2.0/client/service_orders/_activeState
Request Method:GET
Status Code:200
Remote Address:[::1]:8080
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:http://localhost:3000
Content-Type:application/json;charset=UTF-8
Date:Sun, 16 Jul 2017 13:58:39 GMT
Set-Cookie:JSESSIONID=6DA824C819AB48051DC6A63367010DDA;path=/;HttpOnly
Transfer-Encoding:chunked
Vary:Origin
Request Headers
view source
Accept:application/json, text/plain, */*
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.8,fr-CA;q=0.6,fr;q=0.4
Cache-Control:no-cache
Connection:keep-alive
Cookie:io=T6umtNN53FTADnx1AAAA
Host:localhost:8080
Origin:http://localhost:3000
Pragma:no-cache
Referer:http://localhost:3000/
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
边缘请求
Request URL: http://localhost:8080/api/2.0/reception/service-orders/_activeState
Request Method: GET
Status Code: 200 /
- Request Headers
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate
Accept-Language: en-CA
Connection: Keep-Alive
Cookie: JSESSIONID=177FD4191C578793F8BC04D9DB7287A5
Host: localhost:8080
Origin: http://localhost:3000
Referer: http://localhost:3000/
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063
- Response Headers
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://localhost:3000
Content-Type: application/json; charset=UTF-8
Date: Sun, 16 Jul 2017 14:08:26 GMT
Transfer-Encoding: chunked
Vary: Origin
答案 0 :(得分:0)
哦,好吧,
Chrome确实有些可疑。我刚刚从头开始重新安装Chrome,一切都很好。
不知道Chrome发生了什么,因为我没有安装任何新的扩展程序,也没有更改任何设置。
干杯