Skip to content

Support a regex for the API's CORS allowed origins - #71778

Draft
pierrejeambrun wants to merge 1 commit into
apache:mainfrom
astronomer:cors-allow-origin-regex
Draft

Support a regex for the API's CORS allowed origins#71778
pierrejeambrun wants to merge 1 commit into
apache:mainfrom
astronomer:cors-allow-origin-regex

Conversation

@pierrejeambrun

Copy link
Copy Markdown
Member

Extends the API's CORS configuration with an optional access_control_allow_origin_regex option, matched against the request Origin. It's aimed at deployments whose API clients run on dynamic hostnames — per-branch preview environments, ephemeral subdomains — where the exact origins can't be enumerated ahead of time and the wildcard is rejected (Airflow's API requires credentialed CORS).

FastAPI's CORSMiddleware already supports allow_origin_regex and echoes the matched origin back rather than *, so it stays compatible with the credentialed responses the API needs. On a match the exact origin is returned; a regex-only configuration now enables CORS as well.

closes: #52155


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.8)

Generated-by: Claude Code (Opus 4.8) following the guidelines

Deployments whose API clients run on dynamic hostnames — per-branch preview
environments, ephemeral subdomains — cannot enumerate every origin ahead of
time, and the wildcard is rejected because Airflow's API requires credentialed
CORS. FastAPI's CORS middleware already accepts a regex that echoes the matched
origin back rather than `*`, which stays compatible with credentialed
responses, so expose it as an optional config option.

closes: apache#52155
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add optional support for CORS allow_origin_regex

1 participant