From 738a17b9110da49a2999875005f6001ce8162606 Mon Sep 17 00:00:00 2001 From: brobert Date: Tue, 14 Oct 2025 08:36:17 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20desactiva=20precompress=20y=20desactiv?= =?UTF-8?q?a=20compresi=C3=B3n=20en=20proxy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: aider (openrouter/openai/gpt-5) --- apps/web/svelte.config.js | 2 +- proxy.ts | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/apps/web/svelte.config.js b/apps/web/svelte.config.js index 6208ddc..6878d7d 100644 --- a/apps/web/svelte.config.js +++ b/apps/web/svelte.config.js @@ -11,7 +11,7 @@ const config = { // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. // If your environment is not supported, or you settled on a specific environment, switch out the adapter. // See https://svelte.dev/docs/kit/adapters for more information about adapters. - adapter: adapter(), + adapter: adapter({ precompress: false }), csrf: { trustedOrigins: ['*'] } diff --git a/proxy.ts b/proxy.ts index e703cfa..9489f4b 100644 --- a/proxy.ts +++ b/proxy.ts @@ -34,9 +34,13 @@ Bun.serve({ const targetOrigin = routeToBot ? BOT_ORIGIN : WEB_ORIGIN; const targetUrl = targetOrigin + url.pathname + url.search; + const headers = buildForwardHeaders(req); + if (!routeToBot) { + try { headers.set('accept-encoding', 'identity'); } catch {} + } const init: RequestInit = { method: req.method, - headers: buildForwardHeaders(req), + headers, body: req.method === 'GET' || req.method === 'HEAD' ? undefined : req.body, redirect: 'manual', }; @@ -50,6 +54,20 @@ Bun.serve({ } catch {} // Devuelve la respuesta (incluye Set-Cookie, Location, etc.), asegurando Content-Type en assets por si faltase const passthroughHeaders = new Headers(res.headers); + if (!routeToBot) { + try { + // Forzar respuesta sin compresión hacia el cliente + passthroughHeaders.delete('content-encoding'); + passthroughHeaders.delete('vary'); + passthroughHeaders.delete('content-length'); + const cc = passthroughHeaders.get('cache-control'); + if (cc && !/no-transform/i.test(cc)) { + passthroughHeaders.set('cache-control', cc + ', no-transform'); + } else if (!cc) { + passthroughHeaders.set('cache-control', 'no-transform'); + } + } catch {} + } if (!passthroughHeaders.get('content-type')) { if (url.pathname.endsWith('.js')) passthroughHeaders.set('content-type', 'application/javascript; charset=utf-8'); if (url.pathname.endsWith('.css')) passthroughHeaders.set('content-type', 'text/css; charset=utf-8');