Skip to content

Add opt-in CORS configuration to the Python server - #50

Merged
forman merged 1 commit into
mainfrom
forman/49-add_configurable_CORS_support
Jul 27, 2026
Merged

Add opt-in CORS configuration to the Python server#50
forman merged 1 commit into
mainfrom
forman/49-add_configurable_CORS_support

Conversation

@forman

@forman forman commented Jul 27, 2026

Copy link
Copy Markdown
Member

Summary

Adds opt-in Cross-Origin Resource Sharing (CORS) support to the Python RemoteState server.

Closes #49

serve() now accepts cors_origins, allowing deployments to explicitly permit browser HTTP requests from trusted frontend origins. CORS remains disabled by default.

The CORS configuration:

  • permits configured origins only
  • supports browser preflight requests
  • permits all HTTP methods and request headers, including OAuth bearer-token Authorization headers
  • does not enable credentialed requests

Usage

rs.serve(
    service,
    cors_origins=["https://app.example.com"],
)

For intentionally public, token-authenticated APIs:

rs.serve(service, cors_origins=["*"])

Testing

  • Allowed-origin response headers
  • CORS preflight handling
  • Rejection of unconfigured origins
  • Secure default with CORS disabled
  • Python lint and type checks

@forman
forman marked this pull request as ready for review July 27, 2026 11:24
@forman forman self-assigned this Jul 27, 2026

@TejasMorbagal TejasMorbagal left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@forman
forman merged commit 3dd77ba into main Jul 27, 2026
6 checks passed
@forman
forman deleted the forman/49-add_configurable_CORS_support branch July 27, 2026 12:20
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.

Add configurable CORS support to the server

3 participants