fix(examples): allow_origins so browsers can call the deployed codex agent#611
Merged
Merged
Conversation
…agent ADK's web server has a CSRF-style Origin guard: state-changing requests (POST /run_sse, create-session) with an Origin header that isn't allow-listed get 403 "Forbidden: origin not allowed". The deploy entry called get_fast_api_app without allow_origins, so the bundled web UI (and any browser) hit 403 on every turn, while curl (no Origin header) worked. Pass allow_origins=["*"]; the API is already protected by the gateway's Bearer key.
zakahan
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
codex_runtime_on_agentkitdeploy entry calledget_fast_api_app(agents_dir=..., web=False)withoutallow_origins, so ADK's web server rejected browser requests.Why
ADK's web server has a CSRF-style Origin guard (
adk_web_server.py):/run_sse, create-session) whoseOriginheader isn't allow-listed get 403Forbidden: origin not allowed.Originheader (curl, server-to-server) pass.So the deployed agent worked from
curl(no Origin) but the bundled web UI / any browser hit 403 on every turn (the POST carriesOrigin: http://...). The allow-list was empty becauseallow_originswasn't passed.Fix
_is_origin_allowedhonors"*". The API is already protected by the AgentKit gateway's Bearer key auth, so opening Origin in this demo is acceptable (tighten to specific origins for stricter setups).Verified on the live runtime
Redeployed to the same runtime and re-tested with an
Originheader (browser simulation):POST .../sessions→ 200 (was 403)POST /run_sse→ 200, real answer streamed back(One-line change to
examples/codex_runtime_on_agentkit/app.py.)