CodeZettaInterview Hub

NestJS · Middleware · Junior · Live Coding

Where do you apply middleware selectively?

Short Interview Answer

In configure(consumer) with .forRoutes / .exclude, by controller or path.

Detailed Explanation

Global middleware applies everywhere — use for logging/correlation IDs. Keep auth preferably in guards for Nest idiomatic style.

Did you know this answer?