From 9e96b1eabc08e74ad62dfcc9d20d34540f9d4be4 Mon Sep 17 00:00:00 2001 From: David Mzareulyan Date: Sun, 5 Jan 2025 13:18:26 +0300 Subject: [PATCH] Force 'Accept-Encoding: identity' in CORS proxy requests We need to receive data unencoded, to prevent the further double-encoding --- app/controllers/api/v2/CorsProxyController.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v2/CorsProxyController.ts b/app/controllers/api/v2/CorsProxyController.ts index 25759d5a..3e3997a0 100644 --- a/app/controllers/api/v2/CorsProxyController.ts +++ b/app/controllers/api/v2/CorsProxyController.ts @@ -56,7 +56,10 @@ export async function proxy(ctx: Context) { const timeoutMs = timeoutDuration.isValid ? timeoutDuration.toMillis() : fallbackTimeoutMs; // Perform the request with timeout - const response = await fetch(url, { signal: AbortSignal.timeout(timeoutMs) }); + const response = await fetch(url, { + headers: { 'Accept-Encoding': 'identity' }, + signal: AbortSignal.timeout(timeoutMs), + }); // Copying to the client: // 1. The response status code