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:
@@ -7,7 +7,7 @@ DB_NAME=talas_v5
|
|||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
|
|
||||||
# Public Settings (Client braucht IP/Domain) , Variablen mit dem Präfix "NEXT_PUBLIC" ist in Browser sichtbar
|
# Public Settings (Client braucht IP/Domain) , Variablen mit dem Präfix "NEXT_PUBLIC" ist in Browser sichtbar
|
||||||
NEXT_PUBLIC_SERVER_URL="http://10.10.0.70"
|
NEXT_PUBLIC_SERVER_URL="http://192.168.10.33"
|
||||||
NEXT_PUBLIC_ENABLE_GEOCODER=true
|
NEXT_PUBLIC_ENABLE_GEOCODER=true
|
||||||
NEXT_PUBLIC_USE_MOCK_API=false
|
NEXT_PUBLIC_USE_MOCK_API=false
|
||||||
NEXT_PUBLIC_DEBUG_LOG=true
|
NEXT_PUBLIC_DEBUG_LOG=true
|
||||||
|
|||||||
16
CHANGELOG.md
16
CHANGELOG.md
@@ -4,6 +4,22 @@ Alle bedeutenden Änderungen an diesem Projekt werden in dieser Datei dokumentie
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## [1.1.76] – 2025-05-17
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- `config.js` angepasst:
|
||||||
|
- Entfernt: `NEXT_PUBLIC_SERVER_URL` aus `.env.local`
|
||||||
|
- Dynamische Berechnung von `serverURL` anhand `window.location` + `NEXT_PUBLIC_API_PORT_MODE`
|
||||||
|
- Zugriff auf Webservices funktioniert jetzt automatisch abhängig von Entwicklungs-/Produktionsumgebung
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Dokumentation ergänzt:
|
||||||
|
- `docs/frontend/config/config.md`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## [1.1.75] – 2025-05-17
|
## [1.1.75] – 2025-05-17
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { InformationCircleIcon } from "@heroicons/react/20/solid";
|
|||||||
import PoiUpdateModal from "../pois/PoiUpdateModal.js";
|
import PoiUpdateModal from "../pois/PoiUpdateModal.js";
|
||||||
import { ToastContainer, toast } from "react-toastify";
|
import { ToastContainer, toast } from "react-toastify";
|
||||||
import plusRoundIcon from "../PlusRoundIcon.js";
|
import plusRoundIcon from "../PlusRoundIcon.js";
|
||||||
import { createAndSetDevices } from "../../utils/createAndSetDevices.js";
|
import { createAndSetDevices } from "../../utils/devices/createAndSetDevices.js";
|
||||||
import { restoreMapSettings, checkOverlappingMarkers } from "../../utils/mapUtils.js";
|
import { restoreMapSettings, checkOverlappingMarkers } from "../../utils/mapUtils.js";
|
||||||
import { APP_VERSION } from "../../config/appVersion.js";
|
import { APP_VERSION } from "../../config/appVersion.js";
|
||||||
import * as layers from "../../config/layers.js";
|
import * as layers from "../../config/layers.js";
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
// /config/appVersion
|
// /config/appVersion
|
||||||
export const APP_VERSION = "1.1.76";
|
export const APP_VERSION = "1.1.77";
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ const standardSideMenu = true;
|
|||||||
const fullSideMenu = false;
|
const fullSideMenu = false;
|
||||||
|
|
||||||
// Server-URL aus Umgebungsvariable holen (nur bei echter API benötigt)
|
// Server-URL aus Umgebungsvariable holen (nur bei echter API benötigt)
|
||||||
const serverURL = process.env.NEXT_PUBLIC_SERVER_URL || "";
|
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
|
||||||
|
|
||||||
|
const serverURL = mode === "dev" ? `${window.location.protocol}//${window.location.hostname}:80` : `${window.location.origin}`;
|
||||||
|
|
||||||
if (!serverURL && !isMockMode()) {
|
if (!serverURL && !isMockMode()) {
|
||||||
throw new Error("Die Umgebungsvariable NEXT_PUBLIC_SERVER_URL ist nicht gesetzt!");
|
throw new Error("Die Umgebungsvariable NEXT_PUBLIC_SERVER_URL ist nicht gesetzt!");
|
||||||
}
|
}
|
||||||
|
|||||||
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