728x90
728x90
[NestJS] JWT Guard 사용 중 에러 (metatype is not a constructor / In order to use "defaultStrategy", please, ensure to import PassportModule in each place where AuthGuard() is being used, Otherwise, passport won't work correctly.)
Java Script2023. 9. 10. 22:30[NestJS] JWT Guard 사용 중 에러 (metatype is not a constructor / In order to use "defaultStrategy", please, ensure to import PassportModule in each place where AuthGuard() is being used, Otherwise, passport won't work correctly.)

에러 메세지 JWT Guard설정 후 테스트를 위해 서버를 실행했을 때 발생 원인 그대로 번역하면 메타타입은 생성자가 아니라는 것 같음. metatype is not a constructor에러는 커스텀 가드를 사용할 때 발생할 수 있는 일반적 오류중 하나이며 @UseGuards() 데코레이터에 가드 클래스를 전달할 때 메타타입 정보가 올바르게 전달되지 않을 때 발생한다고 한다. 즉, 인스턴스를 전달하는 것이 아니라 생성자 함수를 전달해야한다. //before @UseGuards(AuthGuard) //after @UseGuards(AuthGuard()) 문제가 된 부분을 수정해주었음. 새로운 에러 In order to use "defaultStrategy", please, ensure to import..

728x90
728x90
image