fix(deploy): route /api/** to the engine via explicit rewrite (HT-43) - #51
Merged
Conversation
Vercel's zero-config route generation (CLI 55/56) emits a single-segment route (^/api/([^/]+)$) for the bracketed [...path].ts catch-all, 404ing every multi-segment /api/v1/... path in production. Rename the function to api/index.ts and route /api/:path* to it with an explicit vercel.json rewrite — a rewrite selects the serving function but leaves request.url as the original client path, which is all the engine's router needs. Verified live on production: /api/v1/conversations now reaches the engine (its own error envelope + loadConfig fail-fast naming the five not-yet-provisioned Google env vars), where before it hit Vercel's platform 404. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughVercel now rewrites ChangesAPI routing
Estimated code review effort: 1 (Trivial) | ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@api/index.ts`:
- Around line 16-24: Update the stale Vercel entry-point documentation in the
composition root comment to reference api/index.ts instead of api/[...path].ts.
Preserve the surrounding routing explanation and do not change runtime behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 5aaf0987-10a9-417b-9d42-5c75f3b15bcc
📒 Files selected for processing (2)
api/index.tsvercel.json
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
Production requests to any multi-segment API path (
/api/v1/conversations, cron endpoints) returned Vercel's platform 404. Root cause, verified by inspecting the generated.vercel/output/config.json: the CLI's zero-config router turns theapi/[...path].tscatch-all into a single-segment route (^/api/([^/]+)$, param literally named...path), so anything deeper never reaches the function.Fix: rename to
api/index.ts+ an explicitrewritesrule (/api/:path*→/api). A rewrite picks the serving function but preserves the originalrequest.url, which is all the handler uses (the engine's own router does path dispatch). Doc comment updated to record why the catch-all filename is not used.Verification (live, production)
NOT_FOUNDpage.loadConfig's fail-fast naming exactly the five not-yet-provisioned Google env vars (GMAIL_OAUTH_CLIENT_ID/SECRET,GMAIL_PUBSUB_TOPIC/SUBSCRIPTION,GMAIL_PUSH_SERVICE_ACCOUNT). Function bundling, routing, env loading, and the 500 envelope all confirmed working.This PR makes
mainmatch what production is running.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
/api/*are forwarded to the central API handler.Documentation