thisjt
thisjt

Reputation: 344

Access-Control-Allow-Origin by same domain?

XMLHttpRequest cannot load http://server.chatcoding.net:8000/socket.io/
socket.io.js.
Origin http://www.chatcoding.net is not allowed by Access-Control-Allow-Origin. 

That thing is preventing the socket script from loading. What happened here? It's still on the same domain, but why is it emitting that error?

Anyone? Thank you. :)

Upvotes: 3

Views: 4021

Answers (4)

Manjunath Bhadrannavar
Manjunath Bhadrannavar

Reputation: 163

server.chatcoding.net and www.chatcoding.net are basically two different domains(but the subdomains are same).

Upvotes: 0

Yooz
Yooz

Reputation: 2518

You are on a same domain, but different ports (80 and 8000; source). the cross-domain policy is then applied. Try to setup your response header like that :

response.setHeader("Access-Control-Allow-Origin", "*")

Upvotes: 3

Jared
Jared

Reputation: 3016

Looks like a sub-domain issue. You'll need to check who is requesting your page and if they are allowed (such as any sub-domain), send the header.

I used this to answer this question: https://stackoverflow.com/a/9737907/1215393

Upvotes: 0

Marco
Marco

Reputation: 23937

please check if CORS is enabled on your server. Refer to http://enable-cors.org/server.html for help on how to enable it.

Kind regards

Upvotes: 0

Related Questions