[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
A middleware is applied to all routes under a controller even after stating specific route to be applied to.
Only the specified path should be affected by the middleware.
As in this example, all routes under the users controller will be blocked by the middleware instead of only the users/:userId route.
...
consumer.apply(AuthMiddleware).forRoutes(
'users/:userId'
);
...
Nest version: 5.2.0
For Tooling issues:
- Node version: v9.11.1
- Platform: Mac
Others:
Not sure what's the issue here. Could you share a bit more context?
I was trying to apply the AuthMiddleware on my routes but was going to exclude some of the routes per controller on the app. Say for example i have a User and Admin controllers, while i'll protect all routes in Admin, the User Controller has several methods including SignIn and SignUp which is not supposed to be affected by the AuthMiddleware. On previous versions of Nest, i could state the exact paths i want to apply the middleware to. Now it applies to all paths under a controller.
...
consumer.apply(AuthMiddleware)
.forRoutes(
'users/:userId'
);
...
That was supposed to be applied to only the "users/:userId" route, now i can't access all routes under "users"
Actually, it's a duplicate of #779
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.