Skip to content

Add serverless handler for Vercel deployments - #2

Merged
cdlus merged 2 commits into
mainfrom
codex/refactor-proxy-code-into-implementations-mjqgfz
Oct 2, 2025
Merged

Add serverless handler for Vercel deployments#2
cdlus merged 2 commits into
mainfrom
codex/refactor-proxy-code-into-implementations-mjqgfz

Conversation

@cdlus

@cdlus cdlus commented Oct 2, 2025

Copy link
Copy Markdown
Owner

Summary

  • add a reusable HTTP handler constructor so the proxy logic can be embedded in different runtimes
  • introduce a Vercel serverless entrypoint with rewrites so every request runs through the proxy logic
  • document the Vercel deployment flow alongside other hosting options

Testing

  • go test ./... -v

https://chatgpt.com/codex/tasks/task_e_68dee04b54dc8321a1853ca9cf51dcf9

@cdlus
cdlus merged commit a1090f3 into main Oct 2, 2025
1 check failed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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

Comment thread vercel.json
Comment on lines +2 to +5
"rewrites": [
{
"source": "/(.*)",
"destination": "/api/index"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant