automatische environment für mockData in develop ,nach "npm run build" geht autoatisch zu production

This commit is contained in:
ISA
2024-10-23 18:44:11 +02:00
parent 85bda4323c
commit e602a31b7b
15 changed files with 194 additions and 124 deletions

View File

@@ -6,7 +6,15 @@ export async function loadWindowVariables() {
const loadScript = (src) => {
return new Promise((resolve, reject) => {
const script = document.createElement("script");
script.src = `/CPL?${src}`;
//script.src = `/CPL?${src}`;
// Dynamischer Pfad basierend auf der Umgebung
const environment = process.env.NEXT_PUBLIC_NODE_ENV || "production"; // Fallback auf 'production'
if (environment === "production") {
script.src = `/CPL?/${src}`; // Produktions-Pfad
} else {
script.src = `/mockData/${src}`; // Entwicklungs-Pfad
}
script.async = true;
script.onload = () => {
resolve();