Skip to content

[Backend] Add configurable CORS middleware for custom allowed origins - #744

Merged
EDOHWARES merged 1 commit into
SoroLabs:mainfrom
blessedDev-xyz:feature/588-cors-middleware
Aug 1, 2026
Merged

[Backend] Add configurable CORS middleware for custom allowed origins#744
EDOHWARES merged 1 commit into
SoroLabs:mainfrom
blessedDev-xyz:feature/588-cors-middleware

Conversation

@blessedDev-xyz

Copy link
Copy Markdown

Summary

Replace the hardcoded allow_origin(Any) CORS policy with a configurable tower-http middleware that reads allowed origins from the ALLOWED_ORIGINS environment variable.

Changes

  • Added allowed_origins: String field to AppConfig with a default of "" (allow all)
  • Added default_allowed_origins() helper and config default in load_config()
  • Replaced static CorsLayer::new().allow_origin(Any) with dynamic origin parsing: comma-separated ALLOWED_ORIGINS values are parsed into HeaderValue list; empty/unset falls back to Any

Usage

# Restrict to specific origins
ALLOWED_ORIGINS=http://localhost:3000,https://app.example.com cargo run -p soroscope-core

# Allow all (default, backward-compatible)
cargo run -p soroscope-core

Validation

  • cargo check passes with no errors

Closes #588

Replace hardcoded allow_origin(Any) with configurable CORS middleware
that reads ALLOWED_ORIGINS env var (comma-separated list). Falls back
to allow-all (*) when the variable is unset or empty, preserving
current behaviour for local development.

Closes SoroLabs#588
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@blessedDev-xyz 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

@EDOHWARES

Copy link
Copy Markdown
Collaborator

Nice implementation, LGTM!

@EDOHWARES
EDOHWARES merged commit b2d6a25 into SoroLabs:main Aug 1, 2026
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] Add CORS Configuration Middleware for Custom Allowed Origins

3 participants