【问题标题】:Swagger API route giving 404 Not found error - NestJs Swagger ModuleSwagger API 路由给出 404 Not found 错误 - NestJs Swagger 模块
【发布时间】: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


    【解决方案1】:

    好问题,请问有谁能给出答案。我有同样的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-22
      • 1970-01-01
      • 1970-01-01
      • 2021-12-18
      • 2013-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多