Skip to content

feat(cors): implement environment-based CORS allowlist middleware#352

Merged
Pvsaint merged 1 commit intoMetroLogic:mainfrom
GideonBature:env-based
Mar 30, 2026
Merged

feat(cors): implement environment-based CORS allowlist middleware#352
Pvsaint merged 1 commit intoMetroLogic:mainfrom
GideonBature:env-based

Conversation

@GideonBature
Copy link
Copy Markdown
Contributor

This PR:

  • Add CORS_ORIGINS environment variable with documentation in .env.example
  • Introduce cors.middleware.ts with environment-aware CORS configuration
  • Allow all origins in development with credentials support
  • Allow wildcard origin in test environment for easier testing
  • Enforce strict allowlist checking in production with wildcard and subdomain support
  • Replace default cors() usage in app.ts with the new corsMiddleware
  • Add comprehensive unit tests for all environments and edge cases
  • Log warnings for missing or blocked origins in production
  • Expose X-Request-ID header for tracing and set max age to 24 hours

Closes #301

- Add CORS_ORIGINS environment variable with documentation in .env.example
- Introduce cors.middleware.ts with environment-aware CORS configuration
- Allow all origins in development with credentials support
- Allow wildcard origin in test environment for easier testing
- Enforce strict allowlist checking in production with wildcard and subdomain support
- Replace default cors() usage in app.ts with the new corsMiddleware
- Add comprehensive unit tests for all environments and edge cases
- Log warnings for missing or blocked origins in production
- Expose X-Request-ID header for tracing and set max age to 24 hours
@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 30, 2026

@GideonBature Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Pvsaint Pvsaint merged commit d0784b5 into MetroLogic:main Mar 30, 2026
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Backend] CORS: Environment-based allowlist

2 participants