socketio / socket.io-admin-ui

Admin UI for Socket.IO
https://admin.socket.io
MIT License
346 stars 94 forks source link

cors-origin is weird #70

Closed Taxtra closed 1 year ago

Taxtra commented 1 year ago

i am trying to connect * origin to the admin ui, but it doesn't seem to work.

const io = new Server(server, {
  cors: {
    origin: '*',
    credentials: true,
  },
});

instrument(io, {
  auth: false,
  mode: 'development',
});

35 seems to be the same error

the version in the docs is working for me, but i have to allow all origins.

any solutions?

darrachequesne commented 1 year ago

Hi! If you really need to allow all origins, you can use the following solution:

const io = new Server(httpServer, {
  cors: {
    origin: (_req, callback) => {
      callback(null, true);
    },
    credentials: true
  }
});

Added in the documentation here: https://socket.io/docs/v4/server-options/#cors