有没有办法在谷歌的Chrome浏览器上禁用同源策略?


当前回答

我发现最好的方法是在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"

其他回答

我发现最好的方法是在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"

对于Windows:

(使用windows 8.1,chrome 44.0)

首先,关闭谷歌chrome。

然后,打开命令提示符并转到“chrome.exe”所在的文件夹。

( for me: 'chrome.exe' is here "C:\Program Files (x86)\Google\Chrome\Application".

所以我键入:cd C:\Program Files(x86)\Google\Chrome\Application)

现在键入:chrome.exe--禁用web安全

一个新的铬窗口将打开。

关闭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

创建快捷方式:


粘贴命令:

cmd/c start chrome--禁用web安全--用户数据dir=“c:\temp\chrome”


以管理员身份运行

对于使用**Chrome版本60.0.3112.78(解决方案测试和工作的当天)的windows用户,至少到今天为止是2022年11月24日(版本106.05.249.119(官方版本)(64位))。您不需要关闭任何chrome实例。

在桌面上创建快捷方式右键单击快捷方式,然后单击“财产”编辑Target属性将其设置为“C:\Program Files(x86)\Google\Chrome\Application\Chrome.exe”--禁用web安全--用户数据dir=“C:\ChromeDevSession”启动chrome并忽略消息:禁用网络安全不受支持!

注意不要使用这个特定的浏览器实例进行浏览,因为你可能会被黑客入侵!