2017-07-16 33 views
0

我從Chrome中獲得一個奇怪的行爲,我最近並沒有收到這個行爲。一個星期前,我的項目正在向我的REST api(Java spring)發出適當的CORS請求,一切都很好。但昨天,Chrome(59.0.3071.115)不再像以前那樣發送JSESSIONID。它現在發送一個io cookie代替它。那個io cookie似乎與WebSocket有某種關係,我沒有在我的任何代碼中使用它。使用AXIO進行CORS請求時的不同行爲(Chrome vs Edge)

事情是,當我在Edge瀏覽器上嘗試相同的代碼時,一切都很好。 Edge確實發送了我的JSESSIONID cookie,並且沒有發送「io」cookie。

任何人都曾經歷過這個?

這是我的設置和兩個瀏覽器上的請求示例。

設置: 操作系統:Windows 10 SPA:反應,AXIOS(0.16.2) REST:Java中,春天的引導下,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

哦,

那時確實有鉻有鬼。我只是重新安裝了Chrome,一切都很好。

不知道Chrome發生了什麼,因爲我沒有安裝任何新的擴展,也沒有改變任何設置。

乾杯