The security department of the company I work for is against (rightly so) Access-Control-Allow-Origin: *
on the socket.io requests.
The app is not using CORS at all, this is the problem only with socket.io requests.
This is the function I am using to start socket.io after the server is ready:
exports.start = (server) => {
io = exports.socketio.socket.listen(server, {
origins: `https://${server.address().address}:*`,
rejectUnauthorized: false,
wsEngine: 'ws',
transports: ['websocket', 'polling']
});
exports.connect();
};
The issue with that is that first:
- server.address().address
returns something like this ::
- I need to deploy the app on multiple servers with different addresses
- previously there was no origins
property and socket.io was setting the origing to *
- when I test the solution on my local machine setting the origins to: 'https://localhost:3000'
I am still getting Access-Controll-Allow-Origin: *
for some socket.io requests.
Has someone already encountered this issue ?
Any help much appreciated