-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
[feature] add a way to register middlewares for all namespaces #3851
Comments
A "new_namespace" event will be emitted when a new namespace is created: ```js io.on("new_namespace", (namespace) => { // ... }); ``` This could be used for example for registering the same middleware for each namespace. See #3851
I also wanted to register a root main middlewaredid would fire up its handler for all namespaces. I was trying to have the middleware:
called up on a connection to:
but the middleware handler would not fire up. I also tried:
but that also did not fire up. Then I tried with a regex and that again did not fire up. Only when I changed it to the same namespace is in the connection:
did it fire up. But then I would need to have one same middleware for each and every namespace. |
I'm glad I found this, I honestly thought |
This was added in the documentation: https://socket.io/how-to/register-a-global-middleware I'm not sure whether we should add some syntactic sugar over this, so I'm closing this. Please reopen if needed! |
A "new_namespace" event will be emitted when a new namespace is created: ```js io.on("new_namespace", (namespace) => { // ... }); ``` This could be used for example for registering the same middleware for each namespace. See socketio#3851
Is your feature request related to a problem? Please describe.
Since Socket.IO v3, it is not mandatory anymore for the client to connect to the main namespace.
Registering a global middleware which applies to all namespace is thus a bit messier:
Describe the solution you'd like
Describe alternatives you've considered
Registering a global middleware is possible for dynamic namespaces:
Additional context
Related: #3842
The text was updated successfully, but these errors were encountered: