Skip to content

MAINT: Set PYRIT_CORS_ORIGINS env var in Bicep instead of imperatively#1646

Open
adrian-gavrila wants to merge 2 commits intomicrosoft:mainfrom
adrian-gavrila:adrian-gavrila/copyrit-bicep-cors
Open

MAINT: Set PYRIT_CORS_ORIGINS env var in Bicep instead of imperatively#1646
adrian-gavrila wants to merge 2 commits intomicrosoft:mainfrom
adrian-gavrila:adrian-gavrila/copyrit-bicep-cors

Conversation

@adrian-gavrila
Copy link
Copy Markdown
Contributor

@adrian-gavrila adrian-gavrila commented Apr 23, 2026

Description

Folds the manual az containerapp update --set-env-vars PYRIT_CORS_ORIGINS=... step (currently step 5 in infra/README.md) into infra/main.bicep so deploys are self-correcting and the GUI no longer silently breaks on CORS when someone forgets to re-run the command.

The value is computed from acaEnvironment.properties.defaultDomain rather than the container app's own FQDN to avoid a self-reference cycle; ACA's FQDN is deterministically <appName>.<defaultDomain>, so the result matches what the manual command was setting.

Tests and Documentation

  • az bicep build --file infra/main.bicep --stdout - clean.
  • az deployment group what-if -g copyrit-gui-rg-prod - clean Create of containers[0].env[11] resolving to the SPA's existing FQDN.
  • Backend parsing (pyrit/backend/main.py:73) splits on ,; single value parses to a 1-element list as expected.
  • Removed the now-redundant CORS step from infra/README.md.
  • JupyText: N/A (Bicep + Markdown only).

Adrian Gavrila and others added 2 commits April 23, 2026 12:25
The Container App's CORS origin (its own ingress FQDN) was previously

applied via a manual �z containerapp update --set-env-vars step after

every deploy, per infra/README.md step 5. That value drifts whenever the

ACA app gets re-created (new revision suffix, region change) and is easy

to forget on first stand-up.

ACA generates a deterministic FQDN (<appName>.<envDefaultDomain>), so we

can compute the same value at deploy time from upstream resources without

self-referencing the containerApp resource (which would create a cycle).

Setting it as an env var on the container guarantees it stays in sync on

every Bicep deploy and removes the imperative post-deploy step.

Also removes the now-redundant CORS step from infra/README.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Removed comments about CORS origin handling.
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.

1 participant