Closed caolanb10 closed 5 months ago
Solution is
consumer.apply(LoggerMiddleware).forRoutes('(.*)');
Default behaviour is different between express and fastify, this doesn't work for fastify:
consumer.apply(LoggerMiddleware);
Not sure if I'm following. The provided code snippet:
consumer.apply(LoggerMiddleware);
is incorrect for both adapters.
My mistake
Is there an existing issue for this?
Current behavior
NestJs middlewares don't run when fastify is the HTTP adapter
When implementing fastify middleware from the docs: https://docs.nestjs.com/techniques/performance#middleware It doesn't run
Minimum reproduction code
https://stackblitz.com/edit/nestjs-typescript-starter-fvyxvn
Steps to reproduce
main.ts
runs but the LoggerMiddleware applied in the app.module.ts doesn't work.Expected behavior
The logger middleware should work
Package
Other package
No response
NestJS version
10.3.2
Packages versions
Node.js version
v18.20.3
In which operating systems have you tested?
Other
No response