반응형

Nest..js req.user 오류

Nest js를 활용하여 Jwt 토큰을 발급받고 인증하는 과정을 공부하던 중에

req.user에 오류가 발생했다.

 

타입스크립트 passport 라이브러리를 다시 설치하고 다른 코드에 잘못 쓴게 있는지 한참을 찾아봤는데

도통 원인을 발견할 수 없었다.

 

 

https://stackoverflow.com/questions/64234974/ts2339-property-user-does-not-exist-on-type-request

 

TS2339: Property 'user' does not exist on type 'Request'

I am trying to use JwtAuthGuard to distinguish authenticated requests from the unauthenticated ones. I did follow the official Nestjs documentation on authentification, yet, I can't make it work as...

stackoverflow.com

 

그러다 위 글을 보고 문제를 해결했다.

req: Request로 타입을 지정해줬는데

Request를 import 하지 않아 어떤 타입인지 읽지 못해

req.user를 읽을 수 없던 것이었다.

 

import { Request } from 'express';

를 추가해주니 문제가 해결되었다.

 

 

 

+ Recent posts