fix: proxy allow redirect

This commit is contained in:
antebrl
2025-04-18 15:19:23 +02:00
parent f19c674409
commit fb1abd294e

View File

@@ -44,9 +44,17 @@ module.exports = {
return;
}
if (response.statusCode >= 400) {
if (!res.headersSent) {
res.status(response.statusCode);
}
return res.send(body);
}
try {
const proxyBaseUrl = '/proxy/';
const rewrittenBody = ProxyHelperService.rewriteUrls(body, proxyBaseUrl, headers, targetUrl).join('\n');
const responseUrl = response.request.href;
const rewrittenBody = ProxyHelperService.rewriteUrls(body, proxyBaseUrl, headers, responseUrl).join('\n');
res.send(rewrittenBody);
} catch (e) {
console.error('Failed to rewrite URLs:', e);