refactor+docs: serverURL dynamisch, NEXT_PUBLIC_SERVER_URL entfernt (v1.1.76)
- config.js verwendet nun window.location und API_PORT_MODE zur URL-Ermittlung - feste Konfiguration aus .env.local entfällt (bereinigt) - neue Dokumentation: docs/frontend/config/config.md - CHANGELOG.md aktualisiert (v1.1.76)
This commit is contained in:
58
docs/frontend/config/config.md
Normal file
58
docs/frontend/config/config.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# ⚙️ config.js – zentrale Konfiguration und Umgebungssteuerung
|
||||
|
||||
## Zweck
|
||||
|
||||
Diese Datei enthält zentrale Konfigurationswerte, die abhängig von der Umgebung
|
||||
(Entwicklung oder Produktion) dynamisch erzeugt werden.
|
||||
|
||||
---
|
||||
|
||||
## Ersetzungen von Umgebungsvariablen
|
||||
|
||||
Vorher wurden folgende `.env.local` Variablen verwendet:
|
||||
|
||||
- `NEXT_PUBLIC_BASE_URL`
|
||||
- `NEXT_PUBLIC_SERVER_URL`
|
||||
|
||||
Diese wurden ersetzt durch dynamische Berechnung anhand von:
|
||||
|
||||
```env
|
||||
NEXT_PUBLIC_API_PORT_MODE=dev
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Dynamische Berechnung von `serverURL`
|
||||
|
||||
Die Konfiguration entscheidet anhand des Modus:
|
||||
|
||||
```js
|
||||
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
|
||||
|
||||
const serverURL = mode === "dev" ? `${window.location.protocol}//${window.location.hostname}:80` : `${window.location.origin}`;
|
||||
```
|
||||
|
||||
→ Dadurch funktioniert der Code ohne Anpassung bei IP-/Server-Wechseln oder Portunterschieden.
|
||||
|
||||
---
|
||||
|
||||
## Konfigurationswerte
|
||||
|
||||
- `USE_MOCK_API`: aktiviert lokale Mock-Daten
|
||||
- `serverURL`: Basis für Webservice-Aufrufe (`/talas5/...`)
|
||||
- `mapGisStationsStaticDistrictUrl`: komplette zusammengesetzte URL
|
||||
- `useMockStationData`: true/false aus `.env.local`
|
||||
|
||||
---
|
||||
|
||||
## Vorteile
|
||||
|
||||
| Punkt | Vorteil |
|
||||
| ------------------------------- | ---------------------------------------- |
|
||||
| Keine festen IPs oder Ports | ✅ Weniger Fehler, einfacher Umzug |
|
||||
| Einheitlich mit anderen Dateien | ✅ Gleiche Struktur wie Webservice-Setup |
|
||||
| Lesbar & leicht anpassbar | ✅ Auch ohne Doku sofort verständlich |
|
||||
|
||||
---
|
||||
|
||||
📄 Pfad: `/docs/frontend/config/config.md`
|
||||
Reference in New Issue
Block a user