fix(ag-ui-proxy): name function in route dest so Vercel actually invokes it#589
Merged
Conversation
…y invoked
Production smoke: even a direct GET/POST to /ag-ui-proxy/streaming returned
Vercel NOT_FOUND — the function was never reachable. A Vercel Build Output
function is only invoked when a route's `dest` names its catch-all
(`[[...path]]`); the filesystem handle does NOT auto-serve catch-all
functions. The previous dest `/ag-ui-proxy/$1$2` produced a plain path that
matched no function.
Mirror the proven langgraph rule exactly:
{ src: '^/ag-ui/([^/]+)/agent(/.*)?$', dest: '/ag-ui-proxy/[[...path]]', check: true }
Vercel invokes the function and preserves the ORIGINAL request URL in
req.url, so parseProxyPath now parses the public `/ag-ui/<topic>/agent[/rest]`
path (was parsing the rewritten `/ag-ui-proxy/...`). Also preserve any
query string on the upstream Railway call.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
After #587 moved the proxy out of
/api/, production smoke showed a direct request to/ag-ui-proxy/streamingreturning Vercel's ownNOT_FOUND— the function was unreachable, not just the route.Root cause: a Vercel Build Output API function is only invoked when a route's
destnames its catch-all placeholder ([[...path]]). The{ handle: 'filesystem' }phase does not auto-serve catch-all functions. The previousdest: '/ag-ui-proxy/$1$2'produced a literal path (/ag-ui-proxy/streaming) that matched no static file and no function → 404.The langgraph proxy works because its route names the function:
{ src: '^/api/(.*)', dest: '/api/[[...path]]' }.Fix
Mirror the langgraph rule exactly:
Vercel invokes the
ag-ui-proxycatch-all function and preserves the original request URL inreq.url(same mechanism langgraph relies on). SoparseProxyPathnow parses the public/ag-ui/<topic>/agent[/rest]path instead of the rewritten/ag-ui-proxy/.... Also preserves query strings on the upstream Railway call.Verified locally: esbuild bundles clean; parse logic unit-checked (
/ag-ui/streaming/agent→ topic=streaming;/ag-ui/interrupts/agent/foo/bar→ topic=interrupts, rest=/foo/bar).Test plan (post-merge, against examples.threadplane.ai)
POST /ag-ui/streaming/agentwith allowed Origin → streaming AG-UI SSE (RUN_STARTED … RUN_FINISHED){"error":"origin_not_allowed"}GET /ag-ui/streaming/→ 200 (SPA unaffected)🤖 Generated with Claude Code