在http:// local ip /处设置了与跨站点资源关联的cookie,但未设置“ SameSite”属性。

时间:2019-11-18 06:48:48

标签: google-chrome cordova samesite

试图在Cordova应用程序中调用本地主机URL,但出现以下错误

A cookie associated with a cross-site resource at http://local_ip/ was set without the `SameSite` 
attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are 
set with `SameSite=None` and `Secure`. You can review cookies in developer tools under 
Application>Storage>Cookies and see more details at 
https://www.chromestatus.com/feature/5088147346030592 and 
https://www.chromestatus.com/feature/5633521622188032.

此错误

 Resource interpreted as Document but transferred with MIME type application/vnd.ms-excel: 
"http://local_ip:8083/api/getMailReport? reportType=MU&surId=SUR00002&selectedFromDate=05%2F11%2F2019&selectedToDate=11%2F11%2F2019&lang=E&gener 
ateReport=Generate+Report".

如何克服这个问题

1 个答案:

答案 0 :(得分:1)

Chrome将更改其在Chrome 80中的行为,以应用两个新规则:

  1. 不具有属性SameSite的Cookie会默认被视为SameSite=Lax,即它们将仅是第一方或同一站点
  2. 供第三方或跨站点使用的cookie必须标记为SameSite=None; Secure

控制台警告仅是通知您,您将需要根据站点需要的行为向Cookie添加相关属性。

有关更多信息,您可以看到https://web.dev/samesite-cookies-explainedhttps://web.dev/samesite-cookie-recipes