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:
@@ -1,4 +1,11 @@
|
||||
// config/paths.js
|
||||
const basePathRaw = process.env.NEXT_PUBLIC_BASE_PATH || "";
|
||||
const BASE_PATH = basePathRaw.replace(/^\/|\/$/g, "");
|
||||
export const BASE_URL = BASE_PATH ? `/${BASE_PATH}` : "";
|
||||
let __configCache;
|
||||
export async function getBaseUrl() {
|
||||
if (__configCache) return __configCache;
|
||||
const res = await fetch("/config.json");
|
||||
if (!res.ok) throw new Error("config.json konnte nicht geladen werden");
|
||||
const config = await res.json();
|
||||
const basePath = (config.basePath || "").replace(/^\/|\/$/g, "");
|
||||
__configCache = basePath ? `/${basePath}` : "";
|
||||
return __configCache;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user