首页 > 解决方案 > 使用全球 AuthGuard 自定义护照策略

问题描述

我已经按照该页面https://docs.nestjs.com/techniques/authentication中的描述实现了 JWT 身份验证

当我@UseGuard为特定控制器使用装饰器时,它可以正常工作。但是,如果我将其设置为main.tsusing useGlobalGuards,则不使用我的策略,并且可能使用默认策略。

app.useGlobalGuards(new (AuthGuard('jwt')));

我究竟做错了什么?

标签: node.jstypescriptpassport.jsnestjs

解决方案


推荐阅读