Replace Cloudflare Worker CORS proxy with corsproxy.io#18
Merged
RickyNotaro merged 1 commit intomasterfrom Mar 15, 2026
Merged
Conversation
The reservauto.net API was blocking Cloudflare IP ranges, causing all production requests to fail. Replace the Cloudflare Worker proxy with corsproxy.io using an axios request interceptor that rewrites each request URL to the corsproxy.io/?url= format at runtime. Also removes the now-unused VITE_CORS_PROXY_URL env var from env.d.ts and the deploy workflow. https://claude.ai/code/session_011UEHHFzjkX75EV5LNeK76v
There was a problem hiding this comment.
Pull request overview
This PR replaces a custom Cloudflare Worker CORS proxy with the public corsproxy.io service for production API requests. An axios request interceptor rewrites outgoing requests to route through corsproxy.io, and the related environment variable and CI configuration are removed.
Changes:
- Added an axios request interceptor that rewrites production requests to go through
corsproxy.io - Removed the
VITE_CORS_PROXY_URLenvironment variable from type definitions and the GitHub Actions deploy workflow - Simplified the
apiClientbase URL configuration
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/http-common.ts | Replaced Cloudflare Worker proxy URL with corsproxy.io interceptor logic |
| env.d.ts | Removed VITE_CORS_PROXY_URL from TypeScript env type definitions |
| .github/workflows/deploy.yml | Removed VITE_CORS_PROXY_URL env var from the build step |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Public API client — proxied through Vite in dev, Cloudflare Worker in prod. | ||
| const TARGET_BASE = 'https://www.reservauto.net'; | ||
|
|
||
| // Public API client — proxied through Vite in dev, corsproxy.io in prod. |
Comment on lines
+14
to
+24
| if (!import.meta.env.DEV) { | ||
| apiClient.interceptors.request.use((config) => { | ||
| const targetUrl = new URL(config.url!, TARGET_BASE); | ||
| if (config.params) { | ||
| for (const [k, v] of Object.entries(config.params as Record<string, unknown>)) { | ||
| if (v !== undefined && v !== null) targetUrl.searchParams.set(k, String(v)); | ||
| } | ||
| config.params = undefined; | ||
| } | ||
| config.baseURL = ''; | ||
| config.url = `https://corsproxy.io/?url=${encodeURIComponent(targetUrl.toString())}`; |
|
|
||
| if (!import.meta.env.DEV) { | ||
| apiClient.interceptors.request.use((config) => { | ||
| const targetUrl = new URL(config.url!, TARGET_BASE); |
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
This PR removes the dependency on a custom Cloudflare Worker CORS proxy and replaces it with the public corsproxy.io service. The implementation now uses a request interceptor to dynamically route production requests through corsproxy.io while maintaining the existing dev proxy behavior.
Key Changes
VITE_CORS_PROXY_URLenvironment variable and its associated build-time configurationhttps://www.reservauto.netas the basecorsproxy.io/?url=<encoded-target-url>VITE_CORS_PROXY_URLfrom TypeScript environment types with a clarifying commentImplementation Details
!import.meta.env.DEV)/apiproxy pathhttps://claude.ai/code/session_011UEHHFzjkX75EV5LNeK76v