WebFaction
Community site: login faq

Hi,

I have node.js working on my server but sometimes I have the following error : XMLHttpRequest cannot load http://node.urlc.be/socket.io/1/?t=1363466155964. Origin http://www.urlc.be is not allowed by Access-Control-Allow-Origin.

Can you tell me what's wrong ?

Thanks

asked 16 Mar '13, 15:39

benoitdupont
1633
accept rate: 100%


Hello,

You receive the "Access-Control-Allow-Origin" error when you attempt to perform an illegal cross-domain request. To allow the request, you need to send some special headers in the response. This topic is called "CORS". Take a look at this excellent documentation from Mozilla for all the hairy details.

Your error is specifically referring to the "Origin" header.

Let me know if you have any questions. :)

~Christopher S. | WebFaction Support

permanent link

answered 16 Mar '13, 15:47

likebike
3366
accept rate: 28%

I don't think it's a croos-domain error because everything works perfectly and suddently I have theses errors in my javascript console.

I it was a cross-domain issue the error message should appear from the start and not after some time.

Can it be because of the number of connections ? My website usually have 50 - 100 persons connected to it but right now I have 500 users connected at the same time to node.js

(16 Mar '13, 16:00) benoitdupont

This is definitely a cross-domain issue. It says so in the original error you posted. It says that you are viewing the "www.urlc.be" page, but your javascript is making requests to "node.urlc.be". Unless your Node app includes the proper CORS headers (Origin, etc), your requests will be blocked by your web browser's security system.

One other possibility is that one of the intermediate servers/proxies in front of your Node app is returning an error page; those pages won't include the proper Origin header and then you'll also get that error... but it's still caused by the fact that this is a cross-domain request.

One way to dig deeper into this problem is to use a tool like Wireshark or Burpsuite to record all the traffic that goes across the network. Then you'll be able to see exactly what is being returned from the server and causing this error.

(16 Mar '13, 16:13) likebike

My origins is {origins: ':'} so i guess it's not a configuration problem with my node.js

node.js goes through your nginx proxy I don't know if there is a solution to bypass the proxy ?

(16 Mar '13, 16:35) benoitdupont

Even though you have configured {origins: ':'}, you still need to verify the data that is actually being received by your browser. There might be a bug in your Node code, or your response might be modified on the way out of the server. Burpsuite would be a good tool for this.

Open a support ticket if you want to open a publicly-accessible port that can allow you to bypass the Nginx proxy.

(16 Mar '13, 16:44) likebike

thanks I'll try to replicate the issue and look at my node.js logs and code in details and then use burpsuite. Thanks for your help.

(16 Mar '13, 16:52) benoitdupont
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×67

question asked: 16 Mar '13, 15:39

question was seen: 3,240 times

last updated: 16 Mar '13, 16:52

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM