NestJS · Junior · Question 40 of 75
How do you protect a route with a guard?
- 1
@Guard()on the DTO - 2
app.protect(AuthGuard) - ✓Correct answer:
@UseGuards(AuthGuard)on a method or controller
Explanation
Guards can also be global (app.useGlobalGuards() or the APP_GUARD provider). A common pattern is a global auth guard plus a @Public() decorator for open routes.