Skip to content

fix(examples): allow_origins so browsers can call the deployed codex agent#611

Merged
yaozheng-fang merged 1 commit into
mainfrom
fix/codex-example-allow-origins
Jun 15, 2026
Merged

fix(examples): allow_origins so browsers can call the deployed codex agent#611
yaozheng-fang merged 1 commit into
mainfrom
fix/codex-example-allow-origins

Conversation

@yaozheng-fang

Copy link
Copy Markdown
Collaborator

The codex_runtime_on_agentkit deploy entry called get_fast_api_app(agents_dir=..., web=False) without allow_origins, so ADK's web server rejected browser requests.

Why

ADK's web server has a CSRF-style Origin guard (adk_web_server.py):

  • Safe methods (GET/HEAD/OPTIONS) pass through.
  • State-changing methods (POST /run_sse, create-session) whose Origin header isn't allow-listed get 403 Forbidden: origin not allowed.
  • Requests with no Origin header (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 carries Origin: http://...). The allow-list was empty because allow_origins wasn't passed.

Fix

app = get_fast_api_app(agents_dir=AGENTS_DIR, allow_origins=["*"], web=False)

_is_origin_allowed honors "*". 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 Origin header (browser simulation):

  • create-session POST .../sessions200 (was 403)
  • POST /run_sse200, real answer streamed back

(One-line change to examples/codex_runtime_on_agentkit/app.py.)

…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.
@yaozheng-fang yaozheng-fang merged commit 2aec74f into main Jun 15, 2026
16 checks passed
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.

2 participants