chore: desactiva precompress y desactiva compresión en proxy

Co-authored-by: aider (openrouter/openai/gpt-5) <aider@aider.chat>
webui
brobert 2 weeks ago
parent 6d3754a1fa
commit 738a17b911

@ -11,7 +11,7 @@ const config = {
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. // 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. // 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. // See https://svelte.dev/docs/kit/adapters for more information about adapters.
adapter: adapter(), adapter: adapter({ precompress: false }),
csrf: { csrf: {
trustedOrigins: ['*'] trustedOrigins: ['*']
} }

@ -34,9 +34,13 @@ Bun.serve({
const targetOrigin = routeToBot ? BOT_ORIGIN : WEB_ORIGIN; const targetOrigin = routeToBot ? BOT_ORIGIN : WEB_ORIGIN;
const targetUrl = targetOrigin + url.pathname + url.search; const targetUrl = targetOrigin + url.pathname + url.search;
const headers = buildForwardHeaders(req);
if (!routeToBot) {
try { headers.set('accept-encoding', 'identity'); } catch {}
}
const init: RequestInit = { const init: RequestInit = {
method: req.method, method: req.method,
headers: buildForwardHeaders(req), headers,
body: req.method === 'GET' || req.method === 'HEAD' ? undefined : req.body, body: req.method === 'GET' || req.method === 'HEAD' ? undefined : req.body,
redirect: 'manual', redirect: 'manual',
}; };
@ -50,6 +54,20 @@ Bun.serve({
} catch {} } catch {}
// Devuelve la respuesta (incluye Set-Cookie, Location, etc.), asegurando Content-Type en assets por si faltase // Devuelve la respuesta (incluye Set-Cookie, Location, etc.), asegurando Content-Type en assets por si faltase
const passthroughHeaders = new Headers(res.headers); 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 (!passthroughHeaders.get('content-type')) {
if (url.pathname.endsWith('.js')) passthroughHeaders.set('content-type', 'application/javascript; charset=utf-8'); 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'); if (url.pathname.endsWith('.css')) passthroughHeaders.set('content-type', 'text/css; charset=utf-8');

Loading…
Cancel
Save