|
|
@ -17,14 +17,6 @@ const REQUEST_HEADERS_TO_FORWARD = [ |
|
|
"x-csrftoken", |
|
|
"x-csrftoken", |
|
|
"x-requested-with", |
|
|
"x-requested-with", |
|
|
"x-xsrf-token", |
|
|
"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 = [ |
|
|
const RESPONSE_HEADERS_TO_DROP = [ |
|
|
@ -174,24 +166,15 @@ function getRequestHeaders(request: NextRequest, targetUrl: URL) { |
|
|
headers.set("referer", `${targetUrl.origin}/`); |
|
|
headers.set("referer", `${targetUrl.origin}/`); |
|
|
headers.set("user-agent", "dart:io"); |
|
|
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 = |
|
|
const clientIp = |
|
|
request.headers.get("cf-connecting-ip") || |
|
|
request.headers.get("cf-connecting-ip") || |
|
|
request.headers.get("x-real-ip") || |
|
|
request.headers.get("x-real-ip") || |
|
|
request.headers.get("x-forwarded-for")?.split(",")[0]?.trim(); |
|
|
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")) { |
|
|
|
|
|
|
|
|
if (clientIp && !headers.has("x-forwarded-for")) { |
|
|
headers.set("x-forwarded-for", clientIp); |
|
|
headers.set("x-forwarded-for", clientIp); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const cfCountry = request.headers.get("cf-ipcountry"); |
|
|
|
|
|
if (cfCountry) { |
|
|
|
|
|
headers.set("cf-ipcountry", cfCountry); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return headers; |
|
|
return headers; |
|
|
} |
|
|
} |
|
|
|