Skip to content

本地调试不自带cookie但是测试环境可以,比较奇怪 #3619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Nicolas-Gong opened this issue Mar 1, 2021 · 1 comment
Closed

Comments

@Nicolas-Gong
Copy link

在本地做调试时,发现无法自带cookie,在服务器上,也就是测试环境没有存在这个问题,比较奇怪,代码都一直的。
浏览器没有报错,也没有说跨域什么的报错,看请求头直接就不带cookie,登录接口都没问题的,登录是不需要带cookie请求的,也就是说跨域不存在问题,仅仅是请求头不携带cookie。
本地打开的页面域名是:http://localhost:9528
API的域名是:http://tenantapi.cn
API和web端都是一个电脑运行的。一直没找到具体的原因, #562 看过了没有任何帮助。
后端配置:
Access-Control-Allow-Origin: http://localhost:9528
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Cache-Control, Content-Type, Authorization, X-Requested-With, Env, Cookie
前端配置:
withCredentials: true

@Nicolas-Gong
Copy link
Author

已解决,还是因为chrome 版本问题,本地被禁用了,解决办法如下:
在Chrome中访问chrome://flags/,搜索SameSite by default cookies并设置为disabled即可。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant