Origin null is not allowed by Access-Control-Allow-Origin

I got this error in Chrome while testing out a JQuery Mobile application. The problem was that JQuery Mobile app’s index.html was trying to open another local HTML file using “<a href="foo.html …". Opening local files is not allowed by default in Chrome (but works in Firefox and Safari). This is the kind of error you'd get in Chrome:

XMLHttpRequest cannot load file://.../foo.html. 
Origin null is not allowed by Access-Control-Allow-Origin.

To get rid of the error, you can enable local files in Chrome by adding "–allow-file-access-from-files" option (as explained here).

On Mac, I do this but running Chrome using the following command from terminal:

open /Applications/Google\ Chrome.app --args --allow-file-access-from-files

2 thoughts on “Origin null is not allowed by Access-Control-Allow-Origin

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s