Skip to content

fix(docker): configure CORS origins for frontend in Docker Compose - #2333

Open
anshul23102 wants to merge 1 commit into
utksh1:mainfrom
anshul23102:pr-1700-clean
Open

fix(docker): configure CORS origins for frontend in Docker Compose#2333
anshul23102 wants to merge 1 commit into
utksh1:mainfrom
anshul23102:pr-1700-clean

Conversation

@anshul23102

Copy link
Copy Markdown
Contributor

Adds SECUSCAN_CORS_ALLOWED_ORIGINS environment variable to the api service in docker-compose.yml for explicit CORS configuration.

Previously, CORS relied on backend defaults. This change explicitly sets allowed origins to localhost and 127.0.0.1 on common dev/test ports (5173, 3000, 8080), ensuring the frontend can communicate with the backend in containerized environments.

Excludes Docker service names (e.g. http://frontend:5173) since they are internal to the container network and not accessible from browsers.

Includes integration test to validate CORS configuration from environment variables.

GSSoC 2026

Adds SECUSCAN_CORS_ALLOWED_ORIGINS environment variable to the api service
in docker-compose.yml, explicitly configuring which browser origins are allowed
to make requests to the backend API.

Previously, CORS relied on backend defaults. This explicitly sets the allowed
origins to localhost and 127.0.0.1 on common dev/test ports (5173, 3000, 8080),
ensuring the frontend can communicate with the backend in containerized environments.

Excludes Docker service names (e.g. http://frontend:5173) since they are internal
to the container network and not accessible from browsers.

Adds integration test to validate CORS configuration from environment variables.
@anshul23102

Copy link
Copy Markdown
Contributor Author

This is a clean, focused version addressing the Docker/CORS configuration feedback. The previous PR #1700 accumulated unrelated changes; this version contains only:

  • CORS environment variable configuration in docker-compose.yml
  • Integration test validating CORS origins
  • Excludes Docker service names (http://frontend:5173) - only allows browser-accessible origins (localhost, 127.0.0.1)

All CI checks passing. Ready for review.

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added tests only instantiate Settings after mutating os.environ; they do not validate the docker-compose configuration that this PR changes, and the process-wide environment mutation can leak into later tests. Please use pytest's monkeypatch fixture and add coverage that verifies the Compose-provided SECUSCAN_CORS_ALLOWED_ORIGINS value (or otherwise test the actual configuration boundary). Keep the test focused on the behavior this PR changes.

@utksh1 utksh1 added level:beginner 20 pts difficulty label for small beginner-friendly PRs type:bug Bug fix work category bonus label type:testing Testing work category bonus label area:backend Backend API, database, or service work labels Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend Backend API, database, or service work level:beginner 20 pts difficulty label for small beginner-friendly PRs type:bug Bug fix work category bonus label type:testing Testing work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants