Saturday, April 20, 2013

Webstorm Error : XMLHttpRequest cannot load file. Origin null is not allowed by Access-Control-Allow-Origin

This happens because XMLHttpRequest is not allowed by default in any web browser when running off the local file system.

One way around that is to run in a web server but for simple quick scripts that might be an overkill.

Here's how you can run your site in webstorm without a web server: 

There is a simple flag --allow-file-access-from-files you can set in Chrome to overcome this. Go to your settings:
Then Web Browsers and click on Settings button next to chrome:
Put in the flag and get cracking:
Make sure you have all instances of chrome closed before you start a debug session because the command line flag will only work on a fresh launch of the browser.

Update: or you could always use (for webstorm 6+) : http://localhost:63342/Your_Project_Name which is the built-in web server inside WebStorm.

See how to do it here:

No comments:

Post a Comment