|
|
|
@ -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');
|
|
|
|
|