Skip to content

nsc-events-fullstack_32_183-disable-swagger-api-doc-in-prod#185

Open
NahomAlemu wants to merge 1 commit intomainfrom
183-disable-swagger-api-doc-in-prod
Open

nsc-events-fullstack_32_183-disable-swagger-api-doc-in-prod#185
NahomAlemu wants to merge 1 commit intomainfrom
183-disable-swagger-api-doc-in-prod

Conversation

@NahomAlemu
Copy link
Copy Markdown
Contributor

Summary & Changes 📃

  • Resolves: Issue: Disable Swagger API documentation in production environment #183

  • Summary: Conditionally disable Swagger API documentation in production environments

    • 🔨 Fixes security vulnerability where /api/docs exposes all
      API endpoints, schemas, and authentication mechanisms in
      production
      • 👀 Swagger docs are only available in non-production
        environments (development, test); production returns 404
      • 🗨️ Uses NODE_ENV environment variable check - when set to
        production, Swagger setup is skipped entirely
    • Changes:
      • ✅ Wrapped Swagger configuration in main.ts with NODE_ENV !==
        'production' check
      • ✅ Console log for docs URL also conditionally shown only in
        non-production
      • 🛠️ No breaking changes - production behavior secured,
        development workflow unchanged
      • 📝 Ensure NODE_ENV=production is set in production deployment
        environment

    How to Test 🧪

    1. Steps to Reproduce:
    • Step 1: Run app with NODE_ENV=development → visit /api/docs
    • Step 2: Run app with NODE_ENV=production → visit /api/docs
    1. Expected Behavior:
    • Development: Swagger UI loads normally
    • Production: Returns 404 (route not found)
    1. Actual Behavior (if bug): Previously, Swagger was accessible
      in all environments

Checklist ✅

  • I have tested this PR locally and it works as expected.
  • This PR resolves an issue (Resolves #issue-number).
  • Reviewers, assignees(self), tags, and labels are correctly assigned.
  • Squash commits and enable auto-merge if approved.

@NahomAlemu NahomAlemu self-assigned this Mar 14, 2026
@NahomAlemu NahomAlemu added the security Vulnerability patches, encryption, or access control label Mar 14, 2026
@github-actions
Copy link
Copy Markdown

🚀 E2E Smoke Test Results

Running smoke tests only (non-critical files changed)

Status Count
✅ Passed 5
❌ Failed 0
📊 Total 5

View detailed report

💡 To run full E2E suite, add [e2e-full] to your commit message or trigger manually.

@NahomAlemu NahomAlemu linked an issue Mar 14, 2026 that may be closed by this pull request
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security Vulnerability patches, encryption, or access control

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue: Disable Swagger API documentation in production environment

1 participant