Overriding Access-Control-Allow-Origin restriction in Google Chrome

16

4

I make AJAX calls to URIs which belong to a different domain. Normally in IE I am able to do this via jQuery's CORS support. But this fails in Google Chrome irrespective where CORS support is set or not.

Now I get an error saying something like:

XMLHttpRequest cannot load . Origin http://localhost:8000 is not allowed by Access-Control-Allow-Origin.

Is there a setting in Google Chrome which disables the Access-Control-Allow-Origin restriction?

deostroll

Posted 2012-02-01T19:03:30.457

Reputation: 1 515

1Do you have control over the remote web resource? You could add the Access-Control-Allow-Origin header there. – Jacob Krall – 2012-02-01T20:18:26.140

Answers

18

There is a command-line switch which does the trick: --disable-web-security

Just call it like follows:

$ chromium-browser --disable-web-security http://localhost:8000/pages/index.html

Make sure the Chrome browser is fully closed, otherwise it will only launch a new instance and the applied option will not work.

deostroll

Posted 2012-02-01T19:03:30.457

Reputation: 1 515

The --disable-web-security option doesn't seam to work on Google Chrome, only on Chromium though. – Octavian A. Damiean – 2012-11-20T08:36:58.230

1Tested today in Chrome, works fine. – munissor – 2012-11-20T17:14:29.387

7open -a Google\ Chrome --args --disable-web-security executed in the mac terminal works fine for me. It has to be done when Chrome is not running though. – iolo – 2012-11-21T14:37:31.147

2Tested on 14-12-2012 on Chrome. Works fine but shows a message saying "You are using an unsupported command-line flag: --disable-web-security. Stability and security will suffer" – Vivek Kodira – 2012-12-14T06:05:03.327

"Make sure the Chrome browser is fully closed" -- This was key for me. You should open task manager and make sure all the chrome.exe processes are gone. – Jonah – 2013-08-13T16:34:45.010

If you are using Mac try this one "open -a Google\ Chrome --args --disable-web-security" Without the quote – Hasanavi – 2014-02-04T15:38:59.970