-
Notifications
You must be signed in to change notification settings - Fork 0
Fix/cors #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/cors #16
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances security by implementing environment-aware CORS configuration and adds operational monitoring capabilities. The backend now restricts cross-origin requests based on deployment environment, and the deployment workflow ensures the application runs in production mode.
Key Changes:
- Environment-based CORS origin allowlist (production vs. development)
- Restricted HTTP methods in CORS middleware from wildcard to specific methods
- New
/healthendpoint exposing CORS configuration for debugging
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| backend/main.py | Implements environment detection, conditional CORS origins, restricted HTTP methods, and health check endpoint |
| .github/workflows/google-cloudrun-docker.yml | Sets ENVIRONMENT=production variable for Cloud Run deployments |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| print(f"🔧 CORS Configuration - Production mode: {is_production}") | ||
| print(f"🌐 Allowed origins: {allowed_origins}") |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using print() statements for logging is not recommended in production applications. Replace with proper logging using Python's logging module (e.g., logging.info()) to enable proper log levels, formatting, and integration with cloud logging services.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
🎉 This PR is included in version 2.4.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This pull request improves the backend's security and configurability by introducing environment-aware CORS configuration and a new health check endpoint. It also updates the deployment workflow to set the production environment variable.
Backend CORS configuration and health check:
backend/main.py) now sets allowed CORS origins based on environment variables: in production, only specific frontend URLs are allowed; in development, localhost origins are permitted. This prevents unauthorized cross-origin requests in production./healthendpoint that returns the application's health status and current CORS configuration, making it easier to verify deployment and debug CORS issues.Deployment workflow update:
.github/workflows/google-cloudrun-docker.yml) now sets theENVIRONMENT=productionenvironment variable, ensuring the backend runs in production mode when deployed.