Disable same origin policy in Chrome

2018-12-30 22:55发布

Is there any way to disable the Same-origin policy on Google's Chrome browser?

This is strictly for development, not production use.

26条回答
妖精总统
2楼-- · 2018-12-30 23:17

for mac users:

open -a "Google Chrome" --args --disable-web-security --user-data-dir

and before Chrome 48, you could just use:

open -a "Google Chrome" --args --disable-web-security
查看更多
皆成旧梦
3楼-- · 2018-12-30 23:18

You can use this chrome plugin called "Allow-Control-Allow-Origin: *" ... It make it a dead simple and work very well. check it here: *

Chrome extenstion

查看更多
君临天下
4楼-- · 2018-12-30 23:19

I use this sometimes, for posting a localhost front-end site to a localhost back-end API (e.g. React to an old .NET API). I created a separate shortcut on my Windows 10 desktop, so that it never is used for normal browsing, only for debugging locally. I did the following:-

  1. Right click on desktop, add new shortcut
  2. Add the target as "[PATH_TO_CHROME]\chrome.exe" --disable-web-security
  3. Click OK.

You will get a warning on load of this browser, that it is not secure, just take care with what you browser on it. I tend to rename this new shortcut on the desktop, something in capital, and move it away from my other icons, so it can't be confused for normal Chrome.

Hope this helps!

查看更多
墨雨无痕
5楼-- · 2018-12-30 23:20

On Windows 10, the following will work.

<<path>>\chrome.exe --allow-file-access-from-files --allow-file-access --allow-cross-origin-auth-prompt
查看更多
看淡一切
6楼-- · 2018-12-30 23:21

I find the best way to do this is duplicate a Chrome or Chrome Canary shortcut on your windows desktop. Rename this shortcut to "NO CORS" then edit the properties of that shortcut.

in the target add --disable-web-security --user-data-dir="D:/Chrome" to the end of the target path.

your target should look something like this:

Update: New Flags added.

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

enter image description here

查看更多
冷夜・残月
7楼-- · 2018-12-30 23:21
chromium-browser --disable-web-security --user-data-dir=~/ChromeUserData/
查看更多
登录 后发表回答