有没有办法在谷歌的Chrome浏览器上禁用同源策略?
当前回答
有一个名为CORS Toggle的Chrome扩展。
单击此处访问并将其添加到Chrome。
添加后,将其切换到打开位置以允许跨域请求。
其他回答
对于mac用户:
open -a "Google Chrome" --args --disable-web-security --user-data-dir
在Chrome 48之前,您可以使用:
open -a "Google Chrome" --args --disable-web-security
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
在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。
是的。对于OSX,打开终端并运行:
$ open -a Google\ Chrome --args --disable-web-security --user-data-dir
--OSX上的Chrome 49+需要用户数据目录
对于Linux运行:
$ google-chrome --disable-web-security
此外,如果您试图访问本地文件以用于开发目的,如AJAX或JSON,也可以使用此标志。
--allow-file-access-from-files
对于Windows,进入命令提示符并进入Chrome.exe所在的文件夹,然后键入
chrome.exe --disable-web-security
这将禁用同源策略并允许您访问本地文件。
更新:对于Chrome 22+,您将看到一条错误消息,上面写着:
您正在使用不受支持的命令行标志:--disable web security。稳定和安全将受到影响。
然而,您可以在开发时忽略该信息。
对于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安全
一个新的铬窗口将打开。