CodePark/ questions / Guards & auth
START PRACTICINGPRACTICE
Backend question · NestJS › Guards & auth

A guard's canActivate() returns false. What does the client receive by default?

403 Forbidden

When a guard returns false, Nest throws a ForbiddenException. The client gets a 403 Forbidden.

"401 Unauthorized" is wrong for the default case. To return 401, the guard must throw
UnauthorizedException itself. JWT guards usually do this.