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

@@ -96,6 +96,15 @@ GET /api/clicktt/logs?limit=50&fetchType=leaguePage&association=HeTTV
GET /api/clicktt/url-info
```
## Konfiguration (.env)
Für das Link-Rewriting (Folge-Klicks im iframe) wird die Backend-URL benötigt:
- **BACKEND_BASE_URL** URL, unter der die API erreichbar ist (z.B. `https://tt-tagebuch.de`)
- **BASE_URL** Fallback, falls BACKEND_BASE_URL nicht gesetzt ist
In Produktion mit Reverse-Proxy (Apache) reicht meist `BASE_URL=https://tt-tagebuch.de`. In der Entwicklung kann `BACKEND_BASE_URL=http://localhost:3005` nötig sein, wenn die API auf einem anderen Port als das Frontend läuft.
## Datenbank-Migration
```bash

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({