Currently, I am in the process of incorporating a basic authentication system into my Nest project.
After including the following line in my controller:
@UseGuards(AuthGuard('local'))
I encountered this error message:
ERROR [ExceptionHandler] Cannot read property '__guards__' of undefined
at /home/cedric/Bureau/programmation/project_bank/project/node_modules/@nestjs/core/scanner.js:147:152
Despite closely following the official documentation provided by Nest, this issue persists.
This is what my controller looks like:
@UseGuards(AuthGuard('local'))
@Post('login')
async login(@Request() req) {
console.log(req.body.username);
return req.body.username;
}
As for my auth.guard.ts file:
@Injectable()
export class LocalAuthGuard extends AuthGuard('local') {}