강의

멘토링

로드맵

Inflearn Community Q&A

stronghu956460's profile image
stronghu956460

asked

Slack Clone Coding [Backend with NestJS + TypeORM]

Creating API documentation (Swagger)

브라우저에 localhost:3030 입력시

Written on

·

636

0

제로초님의 Github 을 보기도 했고 영상을 정지하고 따라 해보기도 했습니다만

브라우저에서 localhost:3030 을 입력해서 접속을 하면 화면 캡처 2022-09-23 014322.jpg위 스크린샷과 같이 나오게 됩니다.

에러코드500 은 서버쪽 문제이기에 에러메시지를 확인해보면

 Info  Webpack is building your sources...

webpack 5.74.0 compiled successfully in 656 ms
[Nest] 27340  - 2022. 09. 23. 오전 1:40:04   ERROR [ExceptionsHandler] secret option required for sessions
Error: secret option required for sessions
    at session (E:\Github\Slack\anest\dist\main.js:2474:12)
    at Layer.handle [as handle_request] (E:\Github\Slack\anest\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (E:\Github\Slack\anest\node_modules\express\lib\router\index.js:328:13)
    at E:\Github\Slack\anest\node_modules\express\lib\router\index.js:286:9
    at Function.process_params (E:\Github\Slack\anest\node_modules\express\lib\router\index.js:346:12)
    at next (E:\Github\Slack\anest\node_modules\express\lib\router\index.js:280:10)
    at cookieParser (E:\Github\Slack\anest\node_modules\cookie-parser\index.js:57:14)
    at Layer.handle [as handle_request] (E:\Github\Slack\anest\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (E:\Github\Slack\anest\node_modules\express\lib\router\index.js:328:13)
    at E:\Github\Slack\anest\node_modules\express\lib\router\index.js:286:9
[Nest] 27340  - 2022. 09. 23. 오전 1:40:04   ERROR [ExceptionsHandler] secret option required for sessions
Error: secret option required for sessions
    at session (E:\Github\Slack\anest\dist\main.js:2474:12)
    at Layer.handle [as handle_request] (E:\Github\Slack\anest\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (E:\Github\Slack\anest\node_modules\express\lib\router\index.js:328:13)
    at E:\Github\Slack\anest\node_modules\express\lib\router\index.js:286:9
    at Function.process_params (E:\Github\Slack\anest\node_modules\express\lib\router\index.js:346:12)
    at next (E:\Github\Slack\anest\node_modules\express\lib\router\index.js:280:10)
    at cookieParser (E:\Github\Slack\anest\node_modules\cookie-parser\index.js:57:14)
    at Layer.handle [as handle_request] (E:\Github\Slack\anest\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (E:\Github\Slack\anest\node_modules\express\lib\router\index.js:328:13)
    at E:\Github\Slack\anest\node_modules\express\lib\router\index.js:286:9

이라는 에러메시지를 출력하게 되는데
혹시나 싶어서 구글링을 해보았는데 예전에 다른강좌 에서 답변을 남기신것또한 참고를 해보았으나 해결이 되지 않아 질문 남김니다.
에러 해결을 위해 어느부분을 보면 좋을까요?

NestJSTypeORMnodejsexpress

Quiz

NestJS에서 컨트롤러를 생성할 때 일반적으로 먼저 생성하는 것이 권장되는 주요 구성 요소는 무엇일까요?

Service

Pipe

Module

Guard

Answer 1

1

zerocho님의 프로필 이미지
zerocho
Instructor

.env 파일에 COOKIE_SECRET 넣으세요

Cliche님의 프로필 이미지
Cliche
Questioner

오 안주무시고 계셨군요... 좀더 찾아보니


  app.use(
    session({
      resave: false,
      saveUninitialized: false,
      secret: 'SECRET',
      cookie: {
        httpOnly: true,
      },
    }),
  );

이라고 작성하면 고쳐졌습니다만.. 정확한 해결책은 아니었군요... 감사합니다.

Cliche님의 프로필 이미지
Cliche
Questioner

아그리고 깃헙에서 .env 파일은 어디서 볼 수 있을까요?

zerocho님의 프로필 이미지
zerocho
Instructor

.env는 깃헙에 올리면 안 되는 파일이라 제외했습니다. 파일 만드시고 내부에

COOKIE_SECRET=secret

적으시면 됩니다.

Cliche님의 프로필 이미지
Cliche
Questioner

아~ 그렇군요.. 해결감사합니다.

강좌를 따라 가고 있는데 보면 처음에 main.ts 에 소스를 작성한뒤 그뒤에는 작성을 안하고 이번 강좌에 다시 main.ts에 소스코드를 작성을 하는데 기존에 강좌내에서 작성하지 않은 소스코드들이 영상에선 이미 작성되어서 에러가 발생한것 같습니다.

stronghu956460's profile image
stronghu956460

asked

Ask a question