CodeZettaInterview Hub

NestJS · Authentication · Mid-Level · Live Coding

Global AuthGuard with public routes — pattern?

Short Interview Answer

APP_GUARD with Reflector checking @Public() metadata to skip auth.

Detailed Explanation

E2e test both public and protected. Don't rely on omission of guards alone in large apps.

Example

if (this.reflector.getAllAndOverride('isPublic', [ctx.getHandler(), ctx.getClass()])) return true;

Did you know this answer?