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


当前回答

在Windows中:

创建快捷方式并设置目标:

“C:\Program Files\Google\Chrome\Application\Chrome.exe”--禁用站点隔离测试--禁用web安全--用户数据dir=“C:\ChromeDevSession”

其他回答

使用当前最新的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的Allow Control Allow Origin插件不起作用。这是针对MacOS的

我将别名chrome='open-n-a/Applications/Google\chrome.app/Contents/MacOS/Google\Chrme--args-user data dir--disable web security'作为别名添加到我的.profile中。

其他命令将禁用我的其他扩展,这将在禁用cors的情况下启动正常的chrome

有一个名为CORS Toggle的Chrome扩展。

单击此处访问并将其添加到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

根据奥拉·卡尔森的回答,最好的方法是在不同的会话中打开不安全的Chrome。这样,您就不必担心关闭所有当前打开的选项卡,也可以使用原始的Chrome会话继续安全地上网。

这些批处理文件应该只适用于Windows。

将其放在Chrome_CORS.bat文件中以便于使用

start "" "c:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir="c:/_chrome_dev" --disable-web-security

这张是给Chrome Canary的。金丝雀_ CORS.bat

start "" "c:\Users\%USERNAME%\AppData\Local\Google\Chrome SxS\Application\chrome.exe" --user-data-dir="c:/_canary_dev" --disable-web-security