• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

swagger 404

23.06.29 16:07 작성 23.06.29 16:08 수정 조회수 377

0

문서와 동일하고 동영상과 동일하게 작성했습니다.

 

npm install --save @nestjs/swagger

 

그런데 404가 뜨네요... 원인을 잘 모르겠습니다.

 import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as process from 'process';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';

declare const module: any;
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const port = process.env.PORT;
await app.listen(port);
console.log(`listening on port ${port}`);

const config = new DocumentBuilder()
.setTitle('Sleact Api')
.setDescription('Sleact 개발을 위한 API 문서')
.setVersion('1.0')
.addTag('sleact')
.build();

const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api', app, document);

if (module.hot) {
module.hot.accept();
module.hot.dispose(() => app.close());
}
}
bootstrap();

 

화면 캡처 2023-06-29 160722.jpg

 

답변 2

·

답변을 작성해보세요.

1

이지수님의 프로필

이지수

질문자

2023.06.29

알고보니 순서가 잘못되었습니다. config를 상단으로 넣으니까 해결되었습니다.

네네 app.listen보다 위에있어야합니다

0

이지수님의 프로필

이지수

질문자

2023.06.29

깃헙 코드 붙여넣기 하니까 해결되었습니다. 오타였던 모양입니다.