If we don't import them inside each modules using @AuthGuard decorator then it's showing the following warning in logs.
In order to use "defaultStrategy", please, ensure to import PassportModule in each place where AuthGuard() is being used. Otherwise, passport won't work correctly
@Module({
imports: [
PassportModule.register({ defaultStrategy: 'jwt' }),
JwtModule.register({
secretOrPrivateKey: 'secretKey',
signOptions: {
expiresIn: 3600,
},
}),
UsersModule,
],
providers: [AuthService, JwtStrategy],
})
export class AuthModule {}
Is there any other way besides importing "PassportModule.register({ defaultStrategy: 'jwt' })" inside each modules.