- 低于91版本的Chrome浏览器:
Chrome中访问地址chrome://flags/#same-site-by-default-cookies
,将SameSite by default cookies
设置为Disabled
后重启浏览器再运行项目即可解决。该设置默认情况下会将未指定SameSite属性的请求看做SameSite=Lax
来处理。
- 91版本及以上的Chrome浏览器:(方案1中的设置在91版本后已被Chorme移除)
Windows:打开Chrome快捷方式的属性,在目标
后添加-disable-features=SameSiteByDefaultCookies
,点击确定,关闭所有Chrome窗口包括Chrome浏览器后再重启浏览器运行项目即可解决。
Mac:Mac系统下可以通过命令行携带参数打开浏览器的方式来解决,前提须关闭所有浏览器窗口并退出
浏览器后再进行操作。
- 开启Chrome命令:
open -a "Google Chrome" --args --disable-features=SameSiteByDefaultCookies
- 开启Chromium版Edge浏览器命令:
open -a "Microsoft Edge" --args --disable-features=SameSiteByDefaultCookies
- 94及以上版本的Chrome浏览器
Chromium项目官网提到在94版本通过命令行禁用设置SameSite默认值的方式会被移除,到时方案1和方案2的方式都将无法使用,后续可通过nginx等代理工具或软件将跨域请求转为非跨域请求来解决改问题。
The flags #same-site-by-default-cookies and #cookies-without-same-site-must-be-secure have been removed from chrome://flags as of Chrome 91, as the behavior is now enabled by default. In Chrome 94, the command-line flag --disable-features=SameSiteByDefaultCookies,CookiesWithoutSameSiteMustBeSecure will be removed.
实测: 添加-disable-features=SameSiteByDefaultCookies 这个之后 windows的就可以跨域了。
作者:NgZaamPaang
链接:https://juejin.cn/post/6967695146322247716
来源:掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。