Skip to content

Replace Cloudflare Worker CORS proxy with corsproxy.io#18

Merged
RickyNotaro merged 1 commit intomasterfrom
claude/corsproxy-cloudflare-bypass-4xt7h
Mar 15, 2026
Merged

Replace Cloudflare Worker CORS proxy with corsproxy.io#18
RickyNotaro merged 1 commit intomasterfrom
claude/corsproxy-cloudflare-bypass-4xt7h

Conversation

@RickyNotaro
Copy link
Owner

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

  • Removed custom CORS proxy configuration: Eliminated the VITE_CORS_PROXY_URL environment variable and its associated build-time configuration
  • Implemented request interceptor: Added an axios request interceptor for production builds that:
    • Constructs the full target URL using https://www.reservauto.net as the base
    • Migrates query parameters from axios config to URL search params
    • Routes the request through corsproxy.io/?url=<encoded-target-url>
  • Simplified environment setup: Removed the need to configure custom environment variables in CI/CD workflows
  • Updated type definitions: Removed the VITE_CORS_PROXY_URL from TypeScript environment types with a clarifying comment

Implementation Details

  • The interceptor only activates in production builds (!import.meta.env.DEV)
  • Query parameters are properly encoded and transferred to the URL before proxying
  • The base URL is cleared and the full proxied URL is set in the request config to avoid double-proxying
  • Development builds continue to use the existing /api proxy path

https://claude.ai/code/session_011UEHHFzjkX75EV5LNeK76v

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
Copilot AI review requested due to automatic review settings March 15, 2026 03:46
@RickyNotaro RickyNotaro merged commit 2b82d90 into master Mar 15, 2026
3 checks passed
Copy link

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

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_URL environment variable from type definitions and the GitHub Actions deploy workflow
  • Simplified the apiClient base 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);
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.

3 participants