fix: Make Swagger server URLs fully configurable

- Add configurable server URL from API_BASE_URL env var
- Make production server optional via PRODUCTION_API_URL env var
- Remove hardcoded https://api.goagel.gov.in
- Document PRODUCTION_API_URL in .env.example
This commit is contained in:
Mahi
2026-02-09 09:54:55 -04:00
parent cbcfa43d32
commit 10de6fa630
2 changed files with 15 additions and 2 deletions

View File

@@ -64,6 +64,11 @@ PLATFORM_WALLET_PRIVATE_KEY=
# NODE_ENV=production
# FORCE_RESEED=false
# Production API URL for Swagger documentation
# Only set this when you have a production domain configured
# Example: https://api.goagel.gov.in
# PRODUCTION_API_URL=
# External ports (if defaults conflict)
# API_PORT=3001
# FRONTEND_PORT=4200

View File

@@ -87,7 +87,7 @@ async function bootstrap(): Promise<void> {
// Swagger documentation
if (swaggerEnabled) {
const swaggerConfig = new DocumentBuilder()
const swaggerBuilder = new DocumentBuilder()
.setTitle('Goa GEL API')
.setDescription('Blockchain Document Verification Platform for Government of Goa')
.setVersion('1.0.0')
@@ -110,7 +110,15 @@ async function bootstrap(): Promise<void> {
'ApiKeyAuth',
)
.addServer(`http://localhost:${port}`, 'Local Development')
.addServer('https://api.goagel.gov.in', 'Production')
.addServer(process.env.API_BASE_URL?.replace('/api/v1', '') || `http://localhost:${port}`, 'Configured Server');
// Add production server only if configured
const productionApiUrl = process.env.PRODUCTION_API_URL;
if (productionApiUrl) {
swaggerBuilder.addServer(productionApiUrl, 'Production');
}
const swaggerConfig = swaggerBuilder
.addTag('Auth', 'Authentication and authorization')
.addTag('Applicants', 'Applicant management')
.addTag('Requests', 'License request operations')