개발일지

Nest.JS 쿠키파서 에러

index.ys 2023. 8. 21. 19:44

쿠키파서 에러

  • 쿠키파서를 적용하기 위해 main.ts에 쿠키파서 모듈 설치 후 적용
  //쿠키파서 모듈 추가
  app.use(cookieParser());
  app.useGlobalPipes(
    new ValidationPipe({
      whitelist: true,
      transform: true,
      transformOptions: {
        enableImplicitConversion: true,
      },
    }),
  );
  • 서버실행시 쿠키파서 에러 발생

해결 방법

  • import한 쿠키파서 모듈의 정의를
import cookieParser from 'cookie-parser';​
  • 아래 모듈로 재정의
import * as cookieParser from 'cookie-parser';​

스택오버플로우 링크

https://stackoverflow.com/questions/63107060/nestjs-adding-cookie-parser-causes-an-error/63107061#63107061?newreg=b1015f7fab8c4b0d81a5eadbf65269f3 

 

NestJS: Adding cookie-parser causes an error

When I run this code: import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import cookieParser from 'cookie-parser'; async function bootstrap() { const app = await

stackoverflow.com