Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. :)

like image 580
thisjt Avatar asked Aug 09 '26 05:08

thisjt


1 Answers

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", "*")
like image 116
Yooz Avatar answered Aug 10 '26 20:08

Yooz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!