feat: basePath-Konfiguration von .env in config.json verschoben

basePath wird jetzt in config.json gepflegt statt als NEXT_PUBLIC_BASE_PATH in .env.*
Alle relevanten Code-Stellen lesen basePath dynamisch aus config.json
Dokumentation und Beispiele in Markdown-Dateien entsprechend angepasst
Erhöhte Flexibilität für Deployments ohne Rebuild
This commit is contained in:
ISA
2025-08-20 08:42:24 +02:00
parent bf4fc95b8e
commit 9a2b438eaf
19 changed files with 135 additions and 47 deletions

View File

@@ -1,7 +1,17 @@
// /services/webservice/fetchGisLinesStatusService.js
let __configCache;
async function getConfig() {
if (__configCache) return __configCache;
const res = await fetch("/config.json");
if (!res.ok) throw new Error("config.json konnte nicht geladen werden");
__configCache = await res.json();
return __configCache;
}
export const fetchGisLinesStatusService = async () => {
const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true";
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
const config = await getConfig();
const basePath = config.basePath || "";
if (useMocks) {
const mockBasePath = "/api/mocks/webservice/gisLinesStatus";
@@ -16,11 +26,9 @@ export const fetchGisLinesStatusService = async () => {
}
const mockData = await response.json();
if (!Array.isArray(mockData.Statis)) {
throw new Error("Ungültige Struktur: 'Status' fehlt im Mock");
}
return mockData.Statis;
} else {
const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`;