Skip to content

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

Merged
pierrejeambrun merged 1 commit into
apache:mainfrom
astronomer:cors-allow-origin-regex
Sep 7, 2026
Merged

pierrejeambrun merged 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
@pierrejeambrun
pierrejeambrun force-pushed the cors-allow-origin-regex branch from 19dab85 to 1a0eebc Compare August 19, 2026 10:48
@pierrejeambrun pierrejeambrun added this to the Airflow 3.4.0 milestone Aug 20, 2026
@pierrejeambrun pierrejeambrun self-assigned this Aug 20, 2026

@jason810496 jason810496 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, I checked the FastAPI docs, and this LGTM.

@pierrejeambrun
pierrejeambrun merged commit b3bcf9f into apache:main Sep 7, 2026
84 checks passed
@pierrejeambrun
pierrejeambrun deleted the cors-allow-origin-regex branch September 7, 2026 14:05
pierrejeambrun added a commit to astronomer/airflow that referenced this pull request Sep 8, 2026
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
imrichardwu pushed a commit to imrichardwu/airflow that referenced this pull request Sep 11, 2026
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
regarmukesh3g pushed a commit to regarmukesh3g/airflow that referenced this pull request Sep 27, 2026
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

3 participants