Skip to content

fix(ag-ui-proxy): move out of /api/ namespace so route doesn't shadow into langgraph proxy#587

Merged
blove merged 1 commit into
mainfrom
claude/ag-ui-proxy-route-fix-v2
Jun 6, 2026
Merged

fix(ag-ui-proxy): move out of /api/ namespace so route doesn't shadow into langgraph proxy#587
blove merged 1 commit into
mainfrom
claude/ag-ui-proxy-route-fix-v2

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented Jun 6, 2026

Problem

Production smoke against examples.threadplane.ai showed POST /ag-ui/streaming/agent with an evil Origin returning {"detail":"Not Found"} (FastAPI body) with x-api-key in access-control-allow-headers — meaning the request hit the langgraph proxy at LangGraph Cloud, not the ag-ui-proxy.

Root cause: route table in scripts/assemble-examples.ts:

{ src: '^/ag-ui/([^/]+)/agent(/.*)?$', dest: '/api/ag-ui-proxy/$1$2', check: true },
{ src: '^/api/(.*)',                   dest: '/api/[[...path]]',    check: true },

With check: true, after the first rewrite Vercel re-evaluates routes. /api/ag-ui-proxy/streaming matches rule 2, which rewrites again to the langgraph catch-all function — shadowing our function.

Fix

Move the ag-ui proxy out of /api/:

  • Function path: functions/ag-ui-proxy/[[...path]].func (was functions/api/ag-ui-proxy/...)
  • Route dest: /ag-ui-proxy/$1$2 (was /api/ag-ui-proxy/$1$2)
  • parseProxyPath in ag-ui-proxy.ts updated to expect ['ag-ui-proxy', '<topic>', ...] instead of ['api', 'ag-ui-proxy', '<topic>', ...]

After the rewrite, the path /ag-ui-proxy/<topic> no longer matches the langgraph rule, falls through to the filesystem handle, finds the function, served.

Test plan

  • CI green
  • Post-merge: examples.threadplane.ai/ag-ui/streaming/agent with wrong Origin returns 403 {"error":"origin_not_allowed"}
  • Post-merge: same path with allowed Origin returns streaming AG-UI events

🤖 Generated with Claude Code

The previous route /ag-ui/<t>/agent → /api/ag-ui-proxy/<t> got
shadowed by the langgraph proxy: Vercel's check:true causes route
re-evaluation, and ^/api/(.*) matches the rewritten path before the
filesystem handle can find the ag-ui-proxy function. Production smoke
caught it — requests landed on the langgraph proxy (which returned
404 with FastAPI's body because the rewrite to LangGraph Cloud failed).

Move the function to functions/ag-ui-proxy/[[...path]].func (no /api/
prefix), update the route dest to /ag-ui-proxy/$1$2, and update
parseProxyPath in ag-ui-proxy.ts to expect the new shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@blove blove enabled auto-merge (squash) June 6, 2026 14:16
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
threadplane Ready Ready Preview, Comment Jun 6, 2026 2:18pm

Request Review

@blove blove merged commit cdeaf75 into main Jun 6, 2026
17 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.

1 participant