Skip to content

feat(cors-proxy): add redirect following and refactor callbacks#5

Open
nicomiguelino wants to merge 2 commits intomasterfrom
feat/cors-proxy-redirect-handling
Open

feat(cors-proxy): add redirect following and refactor callbacks#5
nicomiguelino wants to merge 2 commits intomasterfrom
feat/cors-proxy-redirect-handling

Conversation

@nicomiguelino
Copy link
Copy Markdown
Collaborator

Summary

  • Add redirect following (301-308) in the CORS proxy server
  • Set CORS headers on proxied responses
  • Extract inline callbacks into named functions (handleRedirect, handleProxyResponse)

- Add `handleRedirect` to follow 301-308 redirects recursively
- Add `handleProxyResponse` to handle response headers and body piping
- Set CORS headers on proxied responses
- Extract inline callbacks to named functions to stay within line limits
@nicomiguelino nicomiguelino self-assigned this Apr 16, 2026
@nicomiguelino nicomiguelino requested a review from Copilot April 16, 2026 02:06
@nicomiguelino nicomiguelino marked this pull request as ready for review April 16, 2026 02:06
@nicomiguelino nicomiguelino marked this pull request as draft April 16, 2026 02:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds redirect-following behavior and refactors response handling in the development CORS proxy server so proxied responses include CORS headers and redirect logic is centralized.

Changes:

  • Introduces handleRedirect and handleProxyResponse to replace inline callbacks.
  • Adds automatic following of HTTP redirects (301–308).
  • Ensures CORS headers are set on proxied (non-redirect) responses.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/cors-proxy-server.ts Outdated
Comment thread scripts/cors-proxy-server.ts Outdated
Comment thread scripts/cors-proxy-server.ts Outdated
Comment thread scripts/cors-proxy-server.ts
- Reject non-http/https redirect protocols with 502
- Resolve relative Location URLs against the current proxied URL
- Only auto-follow redirects for idempotent methods (GET/HEAD)
- Enforce a 10-hop redirect limit, returning 508 when exceeded
@nicomiguelino nicomiguelino marked this pull request as ready for review April 16, 2026 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants