RSS

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

15 May

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
About these ads
 
2 Comments

Posted by on May 15, 2012 in Chrome, HTTP

 

2 responses to “Origin null is not allowed by Access-Control-Allow-Origin

  1. Peter Jansson (@peter_jansson)

    June 27, 2012 at 9:20 am

    I would very seriously look into any security implications when allowing local file access.

     
  2. Rodrigo Juarez

    January 6, 2013 at 1:04 pm

    I have the same problem with an android application that I’m trying to run locally. Do you know what can I do?

     

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

 
%d bloggers like this: