Socket.io: Multiple origins in options

Created on 24 Jan 2011  路  4Comments  路  Source: socketio/socket.io

Hi,
Could multiple origins be supported in a later version of Socket.IO-node so we may specify either an array of origins or a comma separated list of origins?

Thanks.

Most helpful comment

I've had the same problem. There is nothing about that in docs but it's already available in socket.io.
It should be a list with spacebars.
Example:
io.set('origins', 'http://domain.com:* http://domain.org:* http://domain.net:* http://domain.gov:*');

Those :* are important. Without it, it will not work.

All 4 comments

What was the verdict on this?

I've had the same problem. There is nothing about that in docs but it's already available in socket.io.
It should be a list with spacebars.
Example:
io.set('origins', 'http://domain.com:* http://domain.org:* http://domain.net:* http://domain.gov:*');

Those :* are important. Without it, it will not work.

The :* is for specifying ports and yes it won't work without it.

@Gut6 FYI, your sample code cause security issues.

io.set('origins', 'http://domain.com:* http://domain.org:* http://domain.net:* http://domain.gov:*');

will be processed at here
https://github.com/socketio/socket.io/blob/e0b2cb0c5a9af768a48c43f65643412cc8edc7df/lib/index.js#L87

so omain.com, main.com, ain.com will be passed.

You must use array instead of string, like this:
io.set('origins', ['domain.com:*', 'domain.org:*', 'domain.net:*', 'domain.gov:*']);

Was this page helpful?
0 / 5 - 0 ratings