![](/img/trans.png)
[英]NestJS/Swagger error TS2307: Cannot find module '@nestjs/swagger'
[英]Swagger UI route giving 404 Not found error - NestJs Swagger Module
在我的本地主機上,swagger-ui 文檔 API 路由工作正常 - http:://localhost:3000/api。
但是,當我在服務器(帶有 Apache 服務器的 AWS)上部署 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 文檔時,出現了這個錯誤。
請嘗試這種方式:並清除服務器緩存:
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup("api", app, document, {
swaggerOptions: { defaultModelsExpandDepth: -1 },
增加你的 lambda function 的 memory 它應該可以工作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.