Files
nodeMap/config/urls.js
ISA cdca624874 refactor: basePath als Umgebungsvariable eingeführt (NEXT_PUBLIC_BASE_PATH)
- alle festen "/talas5/" Pfade entfernt
- dynamischer basePath für API-Links und Station öffnen
- README.md und CHANGELOG.md aktualisiert
- Version erhöht auf 1.1.188
2025-05-27 11:58:28 +02:00

24 lines
1013 B
JavaScript

// /config/urls.js
// Dynamische Bestimmung der URLs basierend auf window.location.origin ohne Port
let BASE_URL, SERVER_URL, PROXY_TARGET, OFFLINE_TILE_LAYER, MAP_TILES_LAYER;
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
if (typeof window !== "undefined") {
// Client-seitige Logik
const url = new URL(window.location.origin);
const originWithoutPort = `${url.protocol}//${url.hostname}`; // Protokoll und Hostname, ohne Port
BASE_URL = `${originWithoutPort}/api`; // Dynamische Basis-URL
SERVER_URL = originWithoutPort; // Dynamisch ermittelt, ohne Port
PROXY_TARGET = `${originWithoutPort}:4000`; // Dynamisch für einen Proxy
OFFLINE_TILE_LAYER = `${originWithoutPort}${basePath}/TileMap/mapTiles/{z}/{x}/{y}.png`; //Map von Talas_v5 Server
//console.log("OFFLINE_TILE_LAYER: ", OFFLINE_TILE_LAYER);
MAP_TILES_LAYER = OFFLINE_TILE_LAYER; // Standardwert
}
// Export der dynamischen Werte
export { BASE_URL, SERVER_URL, PROXY_TARGET, OFFLINE_TILE_LAYER, MAP_TILES_LAYER };