feat: rewrite CSS url() paths in proxy so backgrounds load

This commit is contained in:
aedes
2026-04-21 17:07:05 +03:00
parent 02725cf31b
commit 097ed32f11

View File

@@ -177,6 +177,10 @@ app.get('/proxy/*', async (req, res) => {
// inject a <base> so unrewritten relative URLs default to proxy root
html = html.replace(/<head[^>]*>/i, m => m + '\n<base href="/proxy/">');
res.send(html);
} else if (ct.includes('text/css')) {
let css = await r.text();
css = css.replace(/url\(\s*(["']?)\/(?!\/)/g, 'url($1https://student.sechenov.ru/');
res.send(css);
} else {
// stream binary/text as-is
const buf = Buffer.from(await r.arrayBuffer());