Files
nodeMap/docs/config/config.md

68 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- /docs/config/config.md -->
# ⚙️ 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`
---
[Zurück zur Übersicht](../README.md)