From 242aa1d7085a82618500b3dc60cf0571a9b420b8 Mon Sep 17 00:00:00 2001 From: william Date: Sat, 31 Oct 2026 22:09:54 +0100 Subject: [PATCH] fix(auth): export JwtModule so JwtAuthGuard works outside AuthModule JwtAuthGuard is instantiated in the DI context of whichever module applies @UseGuards() on it, not AuthModule's. SessionsController is the first consumer outside AuthModule itself, and the app crashed on boot with "Nest can't resolve dependencies of the JwtAuthGuard" because only the guard class, not the JwtModule it depends on, was exported. Found by real end-to-end testing while wiring the Agent 1 frontend: the app had apparently never actually been started since the sessions module was added, since unit tests bypass real DI via .overrideGuard(). Co-Authored-By: Claude Sonnet 5 --- Max API/src/auth/auth.module.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Max API/src/auth/auth.module.ts b/Max API/src/auth/auth.module.ts index 376b9eb..7086b6c 100644 --- a/Max API/src/auth/auth.module.ts +++ b/Max API/src/auth/auth.module.ts @@ -24,6 +24,9 @@ const ACCESS_TOKEN_TTL = '1h'; ], controllers: [AuthController], providers: [AuthService, JwtAuthGuard], - exports: [JwtAuthGuard], + // JwtModule doit aussi etre exporte : JwtAuthGuard est instancie dans le contexte d'injection du + // module CONSOMMATEUR (ex: SessionsModule) quand il est utilise via @UseGuards() hors d'AuthModule, + // et a donc besoin d'y resoudre JwtService lui-meme (sinon UnknownDependenciesException). + exports: [JwtAuthGuard, JwtModule], }) export class AuthModule {}