|
|
|
@ -48,8 +48,13 @@ Bun.serve({
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
console.log(`[proxy] ${req.method} ${url.pathname}${url.search} -> ${routeToBot ? 'bot' : 'web'} ${res.status} (${ms}ms)`);
|
|
|
|
console.log(`[proxy] ${req.method} ${url.pathname}${url.search} -> ${routeToBot ? 'bot' : 'web'} ${res.status} (${ms}ms)`);
|
|
|
|
} catch {}
|
|
|
|
} catch {}
|
|
|
|
// Devuelve la respuesta tal cual (incluye Set-Cookie, Location, etc.)
|
|
|
|
// Devuelve la respuesta (incluye Set-Cookie, Location, etc.), asegurando Content-Type en assets por si faltase
|
|
|
|
return res;
|
|
|
|
const passthroughHeaders = new Headers(res.headers);
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Response(res.body, { status: res.status, headers: passthroughHeaders });
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
const msg = err instanceof Error ? err.message : String(err);
|
|
|
|
const msg = err instanceof Error ? err.message : String(err);
|
|
|
|
console.error(`[proxy] ${req.method} ${url.pathname}${url.search} -> ERROR: ${msg}`);
|
|
|
|
console.error(`[proxy] ${req.method} ${url.pathname}${url.search} -> ERROR: ${msg}`);
|
|
|
|
|