【发布时间】:2022-08-19 14:19:45
【问题描述】:
在我的本地主机上,swagger API 路由运行良好 - http:://localhost:3000/api。
但是,当我在服务器(AWS 和 Apache 服务器)上部署 nestjs 构建时,相同的路由不起作用。
在nestjs \"main.ts\" 文件中,编写了以下代码来初始化swagger。
import { NestFactory } from \'@nestjs/core\';
import { AppModule } from \'./app.module\';
import { SwaggerModule, DocumentBuilder } from \'@nestjs/swagger\';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors();
const config = new DocumentBuilder()
.setTitle(\'Digital Health\')
.setDescription(\'Digital Health API\')
.setVersion(\'1.0\')
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup(\'api\', app, document);
await app.listen(4000);
}
bootstrap();
当我点击后端 API url 访问 swagger 文档时,我收到了这个错误。
标签: node.js nestjs swagger-ui nestjs-swagger