Reputation: 61
On my localhost, swagger-ui document API route is working fine - http:://localhost:3000/api.
But, when I deployed the nestjs build on server (AWS with Apache server), the same route is not working.
In nestjs "main.ts" file, following code is written to initialize 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();
I'm getting this error, when I hit the backend API url to access swagger documentation.
Upvotes: 2
Views: 3277
Reputation: 1
Please try this way! and also clear the server cache :
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup("api", app, document, {
swaggerOptions: { defaultModelsExpandDepth: -1 },
Upvotes: 0