cross-domain issue

1,154 views
Skip to first unread message

pedro.t...@gmail.com

unread,
May 1, 2013, 12:29:13 PM5/1/13
to soc...@googlegroups.com
My sockjs node server is on a different domain from which the page is served.
I'm testing locally, serving static files from port 3000 and websockets server on port 3001.
When trying to connect I get the following error on the console:

87XMLHttpRequest cannot load http://localhost:3001/lists/info. Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin.

Do you know any option that can help me here?

(running latest socksjs-node v0.3.7 anc socksjs-client in th browser).

TIA!

Marek Majkowski

unread,
May 1, 2013, 9:53:52 PM5/1/13
to pedrot...@gmail.com, soc...@googlegroups.com
On Wed, May 1, 2013 at 12:29 PM, <pedro.t...@gmail.com> wrote:
> My sockjs node server is on a different domain from which the page is
> served.
> I'm testing locally, serving static files from port 3000 and websockets
> server on port 3001.
> When trying to connect I get the following error on the console:
>
> 87XMLHttpRequest cannot load http://localhost:3001/lists/info. Origin
> http://localhost:3000 is not allowed by Access-Control-Allow-Origin.
>
> Do you know any option that can help me here?

Not sure. Everything should work. For example when I'm connecting
to http://sockjs.cloudfoundry.com/example-cursors.html
it actually uses different domain underneath (ie: it's cross domain)

The magic headers returned by the server for /info call:

Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:http://sockjs.cloudfoundry.com

How do they look in your case?

Is there a load balancer / proxy in between?

What browser?

Marek

scr...@gmail.com

unread,
May 2, 2013, 12:56:10 PM5/2/13
to soc...@googlegroups.com, pedro.t...@gmail.com
I am getting the same issue.  There isn't a proxy in between.  I'm trying to figure it out.

Marek Majkowski

unread,
May 2, 2013, 1:46:56 PM5/2/13
to scr...@gmail.com, soc...@googlegroups.com, pedro.t...@gmail.com
On Thu, May 2, 2013 at 12:56 PM, <scr...@gmail.com> wrote:
> I am getting the same issue. There isn't a proxy in between. I'm trying to
> figure it out.

Please do let us know if you figured out what the problem might be!

Marek

Marek Majkowski

unread,
May 2, 2013, 1:52:45 PM5/2/13
to SockJS
On Thu, May 2, 2013 at 1:51 PM, Pedro Teixeira <pedro.t...@gmail.com> wrote:
> Hi Marek,
>
> I'm digging into it, and I think I found it. I attached the socks server to
> a restify server and restify us taking control and not letting the attached
> sockjs server take control.
> And x-domain works standalone, so this is most likely the problem.
> Anyway, I'll post a fix here if I find one.

Of course!

This is exactly the error you'd see when sockjs server is not installed
on the server side!

Marek

scr...@gmail.com

unread,
May 2, 2013, 2:43:22 PM5/2/13
to soc...@googlegroups.com, pedro.t...@gmail.com
My particular problem was that I didn't specify a route, such as "/lists".  I was trying to use root with just "/".  On the server-side, I specified a named route and client side connected to it.  This time it worked.  Check if the /lists/info directly and see if it's responding with anything.  It was giving me a 404 before.  I'm using sockjs-tornado btw.

On a side note,  I suggest for development purposes to add a line in your /etc/hosts just in case some of these apps parse window.location for whatever reason.  Example:


On Wednesday, May 1, 2013 11:29:13 AM UTC-5, pedro.t...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages