Debug-Logging zentralisiert: Nutzung von process.env.NEXT_PUBLIC_DEBUG_LOG entfernt und auf getDebugLog() mit config.json umgestellt
- Alle Vorkommen von process.env.NEXT_PUBLIC_DEBUG_LOG entfernt - Debug-Konfiguration erfolgt jetzt ausschließlich über public/config.json - getDebugLog()-Utility überall verwendet - .env-Dateien werden für Debug-Logging nicht mehr benötigt - Alle betroffenen Komponenten, Services und API
This commit is contained in:
26
utils/configUtils.js
Normal file
26
utils/configUtils.js
Normal file
@@ -0,0 +1,26 @@
|
||||
// utils/configUtils.js
|
||||
let __configCache;
|
||||
export 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;
|
||||
}
|
||||
|
||||
// Sync helper for debugLog (for use in event handlers etc.)
|
||||
let debugLogValue;
|
||||
export function getDebugLog() {
|
||||
if (debugLogValue !== undefined) return debugLogValue;
|
||||
// Try to read from window.__appConfig if available (set at app start)
|
||||
if (
|
||||
typeof window !== "undefined" &&
|
||||
window.__appConfig &&
|
||||
typeof window.__appConfig.debugLog !== "undefined"
|
||||
) {
|
||||
debugLogValue = !!window.__appConfig.debugLog;
|
||||
return debugLogValue;
|
||||
}
|
||||
// Fallback: default false
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user