Add serverless handler for Vercel deployments - #2
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting
| "rewrites": [ | ||
| { | ||
| "source": "/(.*)", | ||
| "destination": "/api/index" |
There was a problem hiding this comment.
Preserve original request path in Vercel rewrite
The new serverless deployment rewrites every request to /api/index, but the proxy handler builds the upstream target from r.URL.Path (internal/proxy/passthrough.go around target = p.upstreamOrigin + r.URL.Path). When Vercel applies a rewrite, the function receives the destination path, not the original URL, so every request will be forwarded to https://giscus.app/api/index instead of the requested resource (e.g. /widget). The proxy therefore cannot serve any endpoint when deployed on Vercel. The rewrite needs to pass the original path (for example /api/index$1 or a query parameter) so the handler can reconstruct the upstream URL.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68dee04b54dc8321a1853ca9cf51dcf9