I'm running node.js with socket.io on apache. I have it running on a subdomain (e.g - myapp.mydomain.com:8000) as you can see I'm running it on a different port so that I can access it using myapp.mydomain.com.
Everything works fine in chrome, Opera, IE but FF fails and I get a cross domain error.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://myapp.mydomain.com:8000/socket.io/?EIO=2&transport=polling&t=1429260923523-0. This can be fixed by moving the resource to the same domain or enabling CORS.
Any ideas?
UPDATE:
Added my code as requested:
function handler(req, res) {
fs.readFile('../index.html', function(err, data) {
if (err) {
console.log(err);
res.writeHead(500);
return res.end('Error loading client.html');
}
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.writeHead(200);
res.end(data);
});
}