Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cors-origin is weird #70

Closed
Taxtra opened this issue May 20, 2023 · 1 comment
Closed

cors-origin is weird #70

Taxtra opened this issue May 20, 2023 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@Taxtra
Copy link

Taxtra commented May 20, 2023

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
Copy link
Member

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

@darrachequesne darrachequesne added the documentation Improvements or additions to documentation label May 23, 2023
@Taxtra Taxtra closed this as completed Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants