From d351f32b25420703743ffa2591832d64a1c79c5f Mon Sep 17 00:00:00 2001 From: mortezaei Date: Thu, 20 Aug 2026 17:24:47 +0330 Subject: [PATCH] fix(proxy): remove prohibited CF-* headers to prevent Cloudflare Error 1000 --- src/app/api/proxy/route.ts | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/app/api/proxy/route.ts b/src/app/api/proxy/route.ts index 3c04afd..da51015 100644 --- a/src/app/api/proxy/route.ts +++ b/src/app/api/proxy/route.ts @@ -17,14 +17,6 @@ const REQUEST_HEADERS_TO_FORWARD = [ "x-csrftoken", "x-requested-with", "x-xsrf-token", - "cf-connecting-ip", - "cf-ipcountry", - "cf-ray", - "cf-visitor", - "x-real-ip", - "x-forwarded-for", - "x-forwarded-proto", - "x-forwarded-host", ]; const RESPONSE_HEADERS_TO_DROP = [ @@ -174,23 +166,14 @@ function getRequestHeaders(request: NextRequest, targetUrl: URL) { headers.set("referer", `${targetUrl.origin}/`); headers.set("user-agent", "dart:io"); - // Forward real client IP and Geo headers to Django backend + // Forward standard X-Forwarded-For if client IP is available const clientIp = request.headers.get("cf-connecting-ip") || request.headers.get("x-real-ip") || request.headers.get("x-forwarded-for")?.split(",")[0]?.trim(); - if (clientIp) { - headers.set("cf-connecting-ip", clientIp); - headers.set("x-real-ip", clientIp); - if (!headers.has("x-forwarded-for")) { - headers.set("x-forwarded-for", clientIp); - } - } - - const cfCountry = request.headers.get("cf-ipcountry"); - if (cfCountry) { - headers.set("cf-ipcountry", cfCountry); + if (clientIp && !headers.has("x-forwarded-for")) { + headers.set("x-forwarded-for", clientIp); } return headers;