安装了一个插件,https://chrome.google.com/webstore/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf
但是不论我怎么设置,在本地调试的时候,都会碰到这个 错误。已经在插件里面,勾选了 Access-Control-Allow-Origin 。(不勾选,也不工作,还是报错)
Access to XMLHttpRequest at 'https://xxx.com' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
现在只能 打开 chrome disable security 来工作。("C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --disable-web-security --user-data-dir="C:/temp/chrome")
谢谢!
1
AoEiuV020CN 2022-10-08 18:06:39 +08:00
之前研究过这个,也是这个插件,踩过个坑,
插件开启后,浏览器已经放行了 cors ,但是请求被 service worker 拦截了,而 service worker 里没有放行 cors ,这就不是插件能解决的了, https://github.com/flutter/flutter/issues/103054 |
2
AoEiuV020CN 2022-10-08 18:07:36 +08:00
@AoEiuV020CN #1 总之除了这种情况,我没有遇到 cors 插件不生效的问题,
|
3
estk 2022-10-08 19:00:00 +08:00 via Android
插件可以绕过任意域名的跨域吗?
|
4
letitbesqzr 2022-10-09 09:33:56 +08:00
我感觉还是用代理方便 ,比如 lightproxy 这种
|
5
yazoox OP @letitbesqzr 不太懂,使用 proxy 就能够绕过 CORS 检查?
|
6
letitbesqzr 2022-10-11 08:45:48 +08:00
@yazoox #5 代理修改返回的头部
|
7
Er1c0 2022-10-15 19:40:57 +08:00 1
CORS Unblock - Chrome 应用商店
https://chrome.google.com/webstore/detail/cors-unblock/lfhmikememgdcahcdlaciloancbhjino |