This Question is Answered

2 "helpful" answers available (2 pts)
6 Replies Last post: May 19, 2013 8:13 PM by Gijs Reulen  
Thomas Mulvany Newbie 2 posts since
Mar 10, 2013
Currently Being Moderated

Mar 10, 2013 2:27 AM

Getting error: Origin null is not allowed by Access-Control-Allow-Origin.

I have a small WebStorm project with one html file, one javascript file, and one python file.  In the javascript file, I use jquery to do an AJAX request to local Apache server asking to execute the python file as a CGI file.  This works perfectly when I enter "http://localhost/~<my user name>/TestAjax/ajaxhtml.html" in Google Chrome or Firefox.  The python CGI file works fine.  However, if i enter "file:///Users/<my user name>/Sites/TestAjax/ajaxhtml.html" in Chrome or Firefox, the html file is rendered and the javascript is executed but the AJAX request to access the python CGI file fails.  If i then open the Google Web Inspector, I see this message: "XMLHttpRequest cannot load file:///Users/<my user name>/Sites/TestAjax/ajaxtest.py. Origin null is not allowed by Access-Control-Allow-Origin."  If I try to  debug from the WebStorm project, the browser always uses the "file://" location.  I've tried to use the "localhost" url's in my scripts but haven't been able to get it to work.  When I try to use the "localhost" location in the Run/Debug configuration, I get an error message: "Error: Cannot fine debug file."

 

Anyone run into this and know how to work around it?

 

Thanks.

 

WebStorm 5.0, Chrome 26.0.1410.28 beta, Firefox 19.0.2, Mac OS X 10.8.2

Attachments:
Andriy Bazanov Master 4,169 posts since
May 28, 2010
Currently Being Moderated
Mar 10, 2013 3:21 PM in response to: Thomas Mulvany
Re: Getting error: Origin null is not allowed by Access-Control-Allow-Origin.

Hi Thomas,

 

Define Deployment entry (Settings | Deployment) and mark it as Default for this project -- you will be able to use proper URL (not file:/// ).You may then use Remote JavaScript debug instead of Local (not sure though).

 

I do not know for sure where your project is located, but I guess that deployment entry of "In Place" type should be OK here (a guess based on your URLs/file paths)

 

Some links to read (they are a bit old, but still actual):

 

Alternatively (not recommended though -- it's rather workaround): if you still want to use Chrome as is, start it with the following option: --allow-file-access-from-files

 

In WebStorm browsers are configured in "Preferences | Web Browsers"

Sha Raj Newbie 2 posts since
Apr 3, 2013
Currently Being Moderated
Apr 3, 2013 6:36 PM in response to: Andriy Bazanov
Re: Getting error: Origin null is not allowed by Access-Control-Allow-Origin.

Hi Andriy,

 

It looks like the --allow-file-access-from-files does not work. Could you please give more details?

I tried setting it in the command line settings but  it still does not work. I've attached a screenshot.

 

Thank you,Screen Shot 2013-04-03 at 10.36.07 AM.png

Andriy Bazanov Master 4,169 posts since
May 28, 2010
Currently Being Moderated
Apr 3, 2013 7:06 PM in response to: Sha Raj
Re: Getting error: Origin null is not allowed by Access-Control-Allow-Origin.

Try also specifying --disable-web-security flag -- maybe you need both of them (sorry, I'm not using Chrome myself for developing, so not sure).

 

http://stackoverflow.com/a/6083677/783119

 

 

In any case: make sure that no Chrome browser is running at that time, otherwise old (already running) instance most likely will be used instead (which did not had those options when launched).

 

P.S.

http://peter.sh/experiments/chromium-command-line-switches/

Sha Raj Newbie 2 posts since
Apr 3, 2013
Currently Being Moderated
Apr 3, 2013 7:37 PM in response to: Andriy Bazanov
Re: Getting error: Origin null is not allowed by Access-Control-Allow-Origin.

Great! thanks Andriy,

The solution turns out to be to close all chrome browsers and start the live edit. I didnt need to use --disable-web-security flag.

Another life saver from you. I was struggling with this since morning.

Thank you very much!

Gijs Reulen Newbie 5 posts since
May 19, 2013
Currently Being Moderated
May 19, 2013 8:13 PM in response to: Thomas Mulvany
Re: Getting error: Origin null is not allowed by Access-Control-Allow-Origin.

Same local files / Chrome problem here. And this worked perfectly for me:

 

http://blog.jetbrains.com/webide/2013/03/built-in-server-in-webstorm-6/

 

Great product so far !

More Like This

  • Retrieving data ...