feat(readme): add configuration details for link rewriting and update proxy URL handling

- Introduced a new section in the README for environment variable configuration related to link rewriting, specifying BACKEND_BASE_URL and BASE_URL usage.
- Updated the clickTtHttpPageRoutes to dynamically construct the proxy base URL from environment variables, enhancing flexibility for different deployment environments.
This commit is contained in:
Torsten Schulz (local)
2026-03-10 21:57:43 +01:00
parent c13f426b3d
commit a3148a3781
2 changed files with 13 additions and 3 deletions

View File

@@ -105,9 +105,10 @@ router.get('/proxy', async (req, res, next) => {
.replace(/<meta[^>]*http-equiv=["']x-content-type-options["'][^>]*>/gi, '');
// Links umschreiben: Klicks im iframe laufen über unseren Proxy → Folge-Logs
const protocol = req.protocol || 'http';
const host = req.get('host') || 'localhost:3005';
const proxyBase = `${protocol}://${host}/api/clicktt/proxy`;
// URL aus .env (BACKEND_BASE_URL oder BASE_URL), Fallback: Request-Host
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';
html = rewriteLinksInHtml(html, proxyBase, targetUrl);
res.set({