有没有办法在谷歌的Chrome浏览器上禁用同源策略?
当前回答
在Windows PC上,使用较旧版本的Chrome,该命令将适用于所有人。我把我的Chrome降到了26版,而且效果不错。
其他回答
只有对于OSX Catalina,以下命令对我有效。
open-n-a/Applications/Google\Chrome.app/Contents/MacOS/Google\Chrome--args--用户数据dir=“/tmp/Chrome_dev_test”--禁用web安全
我发现最好的方法是在windows桌面上复制Chrome或Chrome Canary快捷方式。将此快捷方式重命名为“NO CORS”,然后编辑该快捷方式的财产。
在目标路径的末尾添加--disable-web security--user data dir=“D:/Chrome”。
你的目标应该是这样的:
更新:添加了新标志。
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir="D:/Chrome"
关闭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
对于mac用户:
open -a "Google Chrome" --args --disable-web-security --user-data-dir
在Chrome 48之前,您可以使用:
open -a "Google Chrome" --args --disable-web-security
若您在Linux上使用Google Chrome,则以下命令有效。
google-chrome --disable-web-security