fix(ag-ui-proxy): move out of /api/ namespace so route doesn't shadow into langgraph proxy#587
Merged
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
4 tasks
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.
Problem
Production smoke against examples.threadplane.ai showed POST
/ag-ui/streaming/agentwith an evil Origin returning{"detail":"Not Found"}(FastAPI body) withx-api-keyinaccess-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:With
check: true, after the first rewrite Vercel re-evaluates routes./api/ag-ui-proxy/streamingmatches rule 2, which rewrites again to the langgraph catch-all function — shadowing our function.Fix
Move the ag-ui proxy out of
/api/:functions/ag-ui-proxy/[[...path]].func(wasfunctions/api/ag-ui-proxy/...)/ag-ui-proxy/$1$2(was/api/ag-ui-proxy/$1$2)parseProxyPathinag-ui-proxy.tsupdated 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
{"error":"origin_not_allowed"}🤖 Generated with Claude Code