我jwt
在我的nestjs
应用程序中使用令牌,但是当我运行我的项目并使用@UseGuards(AuthGuard())
装饰器调用控制器时,应用程序调试返回以下错误:
Cannot read property 'challenge' of undefined
Run Code Online (Sandbox Code Playgroud)
而不是这一行:
@UseGuards(AuthGuard())
Run Code Online (Sandbox Code Playgroud)
使用这个:
@UseGuards(AuthGuard('jwt'))
Run Code Online (Sandbox Code Playgroud)
你必须导入PassportModule
为
imports: [
TypeOrmModule.forFeature([UserRepository]),
HttpModule,
ConfigModule,
PassportModule.register({ defaultStrategy: 'jwt' }),
],
Run Code Online (Sandbox Code Playgroud)
进入您想要使用默认策略的每个模块。
归档时间: |
|
查看次数: |
1393 次 |
最近记录: |