From 640ae564ff1cb2555ddaaf19d6e1515005c06f8a Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Fri, 2 May 2025 02:31:59 +0300 Subject: [PATCH] Fix base path handling in env script injection for index.html --- frontend/runtimeSetup.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/runtimeSetup.js b/frontend/runtimeSetup.js index 6f86d2c..e656e4b 100644 --- a/frontend/runtimeSetup.js +++ b/frontend/runtimeSetup.js @@ -39,7 +39,8 @@ function updateIndexHtml(envFileName, basePath) { // Replace any existing env script with the new one const envScriptRegex = /`; + const scriptSrc = basePath ? `${basePath.endsWith("/") ? basePath : basePath + "/"}${envFileName}` : envFileName; + const newEnvScript = ``; if (envScriptRegex.test(indexContent)) { indexContent = indexContent.replace(envScriptRegex, newEnvScript); @@ -53,7 +54,7 @@ function updateIndexHtml(envFileName, basePath) { } fs.writeFileSync(indexPath, indexContent, "utf8"); - console.log(`Updated ${indexPath} with base path: ${basePath || "/"} and env script: ${envFileName}`); + console.log(`Updated ${indexPath} with base path: ${basePath || "/"} and env script: ${scriptSrc}`); } function cleanupOldEnvFiles(newEnvFileName) {