Skip to content

Conversation

@karlTGA
Copy link
Contributor

@karlTGA karlTGA commented Jan 8, 2026

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:

  • Added a new CORS_ORIGINS environment variable to the documentation and the Config struct, 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:

  • Introduced a cors_filter function 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]
  • Updated the server startup logic to use the new CORS filter, ensuring all GET and OPTIONS requests respect the configured CORS policy.

@karlTGA karlTGA linked an issue Jan 8, 2026 that may be closed by this pull request
@karlTGA karlTGA requested a review from Copilot January 8, 2026 14:12
@karlTGA karlTGA self-assigned this Jan 8, 2026
Copy link
Contributor

Copilot AI left a 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_ORIGINS environment variable for comma-separated allowed origins list (defaults to allow all origins)
  • Implemented cors_filter function 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.

Copy link
Contributor

Copilot AI commented Jan 8, 2026

@karlTGA I've opened a new pull request, #10, to work on those changes. Once the pull request is ready, I'll request review from you.

karlTGA and others added 4 commits January 8, 2026 16:02
Co-authored-by: karlTGA <12493530+karlTGA@users.noreply.github.com>
[WIP] Fix CORS issues and service authorization necessity
@karlTGA karlTGA merged commit 7749321 into main Jan 8, 2026
2 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.

CORS issues

2 participants