refactor(clickTtHttpPageRoutes): standardize variable names for clarity in proxy response handling

- Renamed variables for the response body and content type to improve code readability and maintainability.
- Ensured consistent usage of the new variable names throughout the proxy response processing logic, enhancing overall code clarity.
This commit is contained in:
Torsten Schulz (local)
2026-03-10 22:10:16 +01:00
parent c5a88324c3
commit bacc6b994d

View File

@@ -272,22 +272,22 @@ router.post('/proxy', async (req, res, next) => {
}
}
let body = result.body;
const contentType = result.contentType || '';
if (body && contentType.includes('text/html')) {
let responseBody = result.body;
const responseContentType = result.contentType || '';
if (responseBody && responseContentType.includes('text/html')) {
const baseUrl = process.env.BACKEND_BASE_URL || process.env.BASE_URL
|| `${req.protocol || 'http'}://${req.get('host') || 'localhost:' + (process.env.PORT || 3005)}`;
const proxyBase = baseUrl.replace(/\/$/, '') + '/api/clicktt/proxy';
body = body
responseBody = responseBody
.replace(/<meta[^>]*http-equiv=["']content-security-policy["'][^>]*>/gi, '')
.replace(/<meta[^>]*http-equiv=["']x-frame-options["'][^>]*>/gi, '');
const pageOrigin = (() => { try { return new URL(targetUrl).origin + '/'; } catch { return null; } })();
if (pageOrigin) {
body = body.replace(/<base[^>]*>/gi, '');
body = body.replace(/<head([^>]*)>/i, `<head$1><base href="${pageOrigin}">`);
responseBody = responseBody.replace(/<base[^>]*>/gi, '');
responseBody = responseBody.replace(/<head([^>]*)>/i, `<head$1><base href="${pageOrigin}">`);
}
body = rewriteLinksInHtml(body, proxyBase, targetUrl, sid);
body = rewriteFormActionsInHtml(body, proxyBase, targetUrl, sid);
responseBody = rewriteLinksInHtml(responseBody, proxyBase, targetUrl, sid);
responseBody = rewriteFormActionsInHtml(responseBody, proxyBase, targetUrl, sid);
}
res.set({
@@ -297,7 +297,7 @@ router.post('/proxy', async (req, res, next) => {
'Content-Security-Policy': 'frame-ancestors *;',
'Cache-Control': 'no-cache, no-store, must-revalidate',
});
res.status(result.status).send(body);
res.status(result.status).send(responseBody);
} catch (error) {
console.error('ClickTT Proxy POST Fehler:', error);
res.status(500).send(