有没有办法在谷歌的Chrome浏览器上禁用同源策略?
当前回答
在Mac终端上尝试此命令-
open -n -a "Google Chrome" --args --user-data-dir=/tmp/temp_chrome_user_data_dir http://localhost:8100/ --disable-web-security
它打开了另一个具有禁用安全性的chrome实例,并且不再存在CORS问题。此外,您不再需要关闭其他chrome实例。将localhost URL更改为您的URL。
其他回答
禁用此标志为chrome-chrome://flags/#reduced-引用者粒度它应该起作用
使用当前最新的chrome版本103.0.5060.134(官方版本)(64位)
windows:单击开始按钮,然后复制粘贴以下内容(根据您的喜好更改D:\temp)。:
chrome.exe --disable-site-isolation-trials --disable-web-security --user-data-dir="D:\temp"
Linux:启动终端,然后运行以下命令(根据需要更改~/tmp目录)
google-chrome --disable-site-isolation-trials --disable-web-security --user-data-dir="~/tmp"
注意:此解决方案将在独立的沙盒中启动chrome,并且不会影响主chrome配置文件。
这个Chrome插件适合我:允许控件允许来源:*-Chrome Web商店
在Windows PC上,使用较旧版本的Chrome,该命令将适用于所有人。我把我的Chrome降到了26版,而且效果不错。
关闭chrome(或chrome)并使用--disable web安全参数重新启动。我刚刚测试了这个,并验证了我可以使用src=“”访问iframe的内容http://google.com嵌入在“localhost”(在chromium 5/ubuntu下测试)提供的页面中
注意:在运行命令之前杀死所有chrome实例
chromium-browser --disable-web-security --user-data-dir="[some directory here]"
浏览器首次打开时会警告您“您正在使用不受支持的命令行”,您可以忽略这一点。
铬源:
// Don't enforce the same-origin policy. (Used by people testing their sites.)
const wchar_t kDisableWebSecurity[] = L"disable-web-security";
在Chrome 48之前,您可以使用:
chromium-browser --disable-web-security