@UseGuards(AuthGuard('jwt')) stopped working after update to latest modules
See original GitHub issueRegression
@UseGuards(AuthGuard(‘jwt’)) stopped working after update to latest modules
Potential Commit/PR that introduced the regression**
Describe the regression
After updating to latest NestJS module using nest u
, running npm run start
leads to error in /node_modules/reflect-metadata/Reflect.js:354
> nest start
/<project_folder>/node_modules/reflect-metadata/Reflect.js:354
throw new TypeError();
^
TypeError
at Object.getMetadata (/<project_folder>/node_modules/reflect-metadata/Reflect.js:354:23)
at Object.extendArrayMetadata (/<project_folder>/node_modules/@nestjs/common/utils/extend-metadata.util.js:4:35)
at UseGuards (/<project_folder>/node_modules/@nestjs/common/decorators/core/use-guards.decorator.js:35:36)
at DecorateProperty (/<project_folder>/node_modules/reflect-metadata/Reflect.js:553:33)
at Object.decorate (/<project_folder>/node_modules/reflect-metadata/Reflect.js:123:24)
at __decorate (/<project_folder>/dist/src/app.controller.js:4:92)
at Object.<anonymous> (//<project_folder>/dist/src/app.controller.js:46:1)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
Input Code
@UseGuards(AuthGuard('jwt'))
@ApiBearerAuth()
@Get('test')
getHelloTest(@CurrentUser() currentUser: CurrentUserInterface): string {
return this.appService.getHello(currentUser.user);
}
Expected behavior/code
Calling npm run start
will run smoothly without errors.
Environment
PRIOR TO UPDATE (WORKING NO RUN ERRORS)
[System Information]
OS Version : macOS Catalina
NodeJS Version : v10.18.1
NPM Version : 6.13.4
[Nest CLI]
Nest CLI Version : 6.14.0 (global)
Nest CLI Version:
[Nest Platform Information]
platform-express version : 6.10.14
platform-fastify version : 6.10.14
passport version : 6.1.1
swagger version : 4.1.15
typeorm version : 6.2.0
common version : 6.10.14
core version : 6.10.14
jwt version : 6.1.1
Outdated Package Current Wanted Latest Location
@nestjs/cli 6.14.0 6.14.1 6.14.1 api-v2
@nestjs/common 6.10.14 6.11.1 6.11.1 api-v2
@nestjs/core 6.10.14 6.11.1 6.11.1 api-v2
@nestjs/platform-express 6.10.14 6.11.1 6.11.1 api-v2
@nestjs/platform-fastify 6.10.14 6.11.1 6.11.1 api-v2
@nestjs/swagger 4.1.15 4.2.0 4.2.0 api-v2
@nestjs/testing 6.10.14 6.11.1 6.11.1 api-v2
@types/hapi__joi 16.0.7 16.0.8 16.0.8 api-v2
@types/jest 24.9.0 24.9.1 24.9.1 api-v2
@types/node 13.1.8 13.5.0 13.5.0 api-v2
mysql 2.18.0 2.18.1 2.18.1 api-v2
ts-jest 24.3.0 24.3.0 25.0.0 api-v2
AFTER UPDATE VIA nest u
[System Information]
OS Version : macOS Catalina
NodeJS Version : v10.18.1
NPM Version : 6.13.4
[Nest CLI]
Nest CLI Version : 6.14.0
[Nest Platform Information]
platform-express version : 6.11.1
platform-fastify version : 6.11.1
passport version : 6.1.1
swagger version : 4.2.0
typeorm version : 6.2.0
common version : 6.11.1
core version : 6.11.1
jwt version : 6.1.1
Outdated Package Current Wanted Latest Location
@nestjs/cli 6.14.0 6.14.1 6.14.1 api-v2
@nestjs/testing 6.10.14 6.11.1 6.11.1 api-v2
@types/hapi__joi 16.0.7 16.0.8 16.0.8 api-v2
@types/jest 24.9.0 24.9.1 24.9.1 api-v2
@types/node 13.1.8 13.5.0 13.5.0 api-v2
mysql 2.18.0 2.18.1 2.18.1 api-v2
ts-jest 24.3.0 24.3.0 25.0.0 api-v2
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (4 by maintainers)
Top Results From Across the Web
UseGuards(AuthGuard('jwt')) stopped working after update to ...
confirming latest nest modules (including @nestjs/swagger) is working with our project, no issues encountered so far on base test. We will know ...
Read more >AuthGuard broken after NestJS Update - Stack Overflow
I have a NestJS (version 6) project that implemented authentication using jwt. The following config worked fine: package.json .
Read more >Authentication | NestJS - A progressive Node.js framework
Authenticate a user by verifying their "credentials" (such as username/password, JSON Web Token (JWT), or identity token from an Identity Provider); Manage ...
Read more >How to implement JWT authentication in NestJS
This command will create a new folder, auth , with an auth.module.ts file; it will also update the app.module.
Read more >Role-Based Authorization with JWT Using NestJS - Shpota
npx @nestjs/cli new role-based-athorization-in-nestj ... @Controller() export class AppController { @UseGuards(AuthGuard('local')) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed in 4.2.2 (
@nestjs/swagger
)This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.