-
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
Default namespace middleware firing #2342
Comments
Hi! I think a similar issue has already been opened here #2124 The middlewares associated with the default namespace '/' are indeed triggered by every request, and there's currently no way to avoid that. A quick "workaround" would be to also use a custom namespace for normal users 🍰 And yes, the documentation could be clearer on that point 😄 |
I see I was hoping to avoid a new namespace, guess I have quite a bit of code to change now! Thankfully I also have tests to help me through the process :) Is this done by design? I guess it kinda makes sense to have a namespace with common middleware in case you got some common logic. But definitely this needs documentation |
That issue was closed automatically. Please check if your issue is fixed with the latest release, and reopen if needed (with a fiddle reproducing the issue if possible). |
@darrachequesne I think this issue should still be addressed, preferably by fixing the inconsistencies between the root namespace |
I'm trying to create a server with the default
/
namespace for normal users and the/admin
namespace for admins, and they both are authenticated in different ways. I wrote two different middlewares for authentication like so:Now, when connecting from the client I do:
Unfortunately, the top middleware gets called even though it shouldn't be. It still gets called even if I change it to
io.of('/').use(normalAuthenticate)
. Is there any way to tell socket.io to use only the middlewares for the namespaces requested?The text was updated successfully, but these errors were encountered: