NestJS - Middleware
You want to apply a middleware only to POST requests on the '/login' route. How can you achieve this in NestJS?
path and method in forRoutes.{ path: '/login', method: RequestMethod.POST }. Use consumer.apply(MyMiddleware).forRoutes('/login') and check method inside middleware applies middleware to all methods on '/login', requiring manual filtering. Apply middleware globally and filter POST requests inside middleware applies globally, which is less efficient. NestJS does not support method-specific middleware is false.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions