Access-Control-Allow-Origin - not possible to host application clients on other hosts
See original GitHub issueI don’t know if its an issue or a ‘feature’ but in the old version I can do something like: io.set(‘Origin’:‘*’)
The reason to do this is because our application will be hosted on many different hostnames (websites) (origins). And only one server host.
In other words, its not possible to host our application clients on other hosts.
We don’t use express or other modules, to keep it as clean as possible. request_handler = require(‘./request_handler’);
inspect = require('util').inspect;
app = require('http').createServer(request_handler.handler);
io = require('socket.io').listen(app,{
'pingTimeout':60000,
'transports':['xhr-polling','polling', 'websocket', 'flashsocket'],
'pingInterval':25000,
'allowUpgrades':true,
'cookie':'io'
});
app.listen(8090);
The error we get is: OPTIONS http://_serverhost__:8090/socket.io/?EIO=2&transport=polling&sid=DWGmxtENtfqN_h1GAAAA No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin 'http://clienthost**’ is therefore not allowed access. v1.js?c=b3f0c7f6bb763af1be91d9e74eabfeb199dc1f1f:5798 XMLHttpRequest cannot load http://serverhost:8090/socket.io/?EIO=2&transport=polling&sid=DWGmxtENtfqN_h1GAAAA. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://**_clienthost****’ is therefore not allowed access.
- I removed the original serverhost name and clienthost
Issue Analytics
- State:
- Created 10 years ago
- Comments:11
Top GitHub Comments
yo lo solvente asi:
You can host your application on a different host but make sure you server the client socket.io.js from the same host where you are trying to connect to.
for example, my initial client code was this and it was throwing CORS error
once I modified it to this, it worked alright.
And my server code is,