正在阻止SameSite cookie

2024-10-05 13:13:34 发布

您现在位置:Python中文网/ 问答频道 /正文

快速概览: 我在域名1打开我的网站。在页面内部,我加载了一个带有url的iframehttp://domain2/...

我一直在chrome上收到这个警告,它影响了我的网站:

A cookie associated with a cross-site resource at http://domain2 was set without the SameSite attribute. It has been blocked, as Chrome now only delivers 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.

我以前从未设置过cookie,所以我不知道cookie应该从哪里设置。我已经尝试在我的域2nginx配置中设置proxy_cookie_path,但似乎不起作用:

location / {
    proxy_cookie_path / "/; SameSite=None; Secure";
}

我还尝试添加了Set-Cookie头,这似乎也不起作用:

location / {
    ...
    add_header 'Set-Cookie' 'SameSite=None; Secure';
}

当我尝试第二种解决方案时,似乎从chrome上的响应中收到了标题,但chrome给出了以下警告:

enter image description here

请注意,域2也是我们的域,它有一个使用Flask框架的python后端。那么,我应该从python代码或javascript前端添加cookie吗

这真的令人沮丧


Tags: andnone警告网站cookiewithsitechrome

热门问题