-
Notifications
You must be signed in to change notification settings - Fork 0
4 cors issues #5
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
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 pull request adds configurable CORS (Cross-Origin Resource Sharing) support to the cell service API, allowing administrators to control which origins can access the endpoints via the CORS_ORIGINS environment variable.
Key changes:
- Introduced
CORS_ORIGINSenvironment variable for comma-separated allowed origins list (defaults to allow all origins) - Implemented
cors_filterfunction in the server module to handle CORS configuration - Applied CORS filter to all API routes including health check and cell query endpoints
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/utils/config.rs | Added cors_origins field to Config struct with parsing logic to split and trim comma-separated origins from environment variable |
| src/utils/server.rs | Implemented cors_filter function with GET and OPTIONS methods support, and integrated CORS filter into route configuration |
| README.md | Added documentation for the new CORS_ORIGINS environment variable with example usage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: karlTGA <12493530+karlTGA@users.noreply.github.com>
[WIP] Fix CORS issues and service authorization necessity
This pull request adds configurable Cross-Origin Resource Sharing (CORS) support to the service, allowing you to restrict which origins can access the API based on an environment variable. The main changes include updating configuration handling, introducing a new CORS filter, and applying it to the server routes.
Configuration and environment variable support:
CORS_ORIGINSenvironment variable to the documentation and theConfigstruct, allowing a comma-separated list of allowed origins to be specified. If not set, all origins are allowed. [1] [2] [3]CORS implementation in the server:
cors_filterfunction that builds a CORS filter using the configured origins and applies it to all routes. If no origins are specified, any origin is allowed. [1] [2]