Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Socket.io access-control-allow=origin error from remote site

I am trying to access a socket.io server from another site. It worked for a few weeks but now I keep getting the following error. It happens when accessing a server on nodester from a server on heroku. The error is:

XMLHttpRequest cannot load http://site2.nodester.com/socket.io/xhr-polling//1311008802545. 
Origin http://site1.heroku.com is not allowed by Access-Control-Allow-Origin.
Resource interpreted as Script but transferred with MIME type text/plain.
Uncaught SyntaxError: Unexpected identifier

Here's how I'm connecting with the socket:

socket = new io.Socket(
    'site2.nodester.com', {port: 80, rememberTransport: false}
);

And here's the server code:

// requires

server = http.createServer(function(req, res){
    // server stuffs
}),

server.listen(8362);

var io = io.listen(server),

// io code
like image 243
JRPete Avatar asked Jul 18 '11 17:07

JRPete


1 Answers

Did you configure socket.io to still use default origins = * or at least put origins = site1.heroku.com

like image 65
Alfred Avatar answered Sep 28 '22 01:09

Alfred