Add CORS middleware for STT web services#35
Conversation
WalkthroughThe pull request adds CORS (Cross-Origin Resource Sharing) support to a FastAPI HTTP server application. A new environment variable Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
ovos_stt_http_server/__init__.py (1)
13-18: CORS middleware wiring looks good; consider handling blank CORS_ORIGINS explicitlyUsing
CORS_ORIGINSfrom the environment, splitting on commas, and wiringCORSMiddlewarewithallow_origins, credentials, methods, and headers is a solid approach and addresses the earlier request to make this configurable via env vars.One small edge case: if
CORS_ORIGINSis set but left empty (CORS_ORIGINS=""),cors_originsbecomes""andoriginsbecomes[""], which effectively disables CORS in a somewhat surprising way. You might optionally special-case this and treat an empty string as either:
- “no CORS” (e.g.,
origins = []), or- “same as default” (e.g., fall back to
"*"),depending on your intended semantics for “empty but defined”.
Also applies to: 110-118
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.env.example(1 hunks)ovos_stt_http_server/__init__.py(2 hunks)
🔇 Additional comments (1)
.env.example (1)
1-1: CORS_ORIGINS example aligns with implementationThe variable name and comma-separated format match the parsing logic in
create_app, so this example should work as-is for typical single- and multi-origin setups.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.