diff --git a/plugins/app-backend/src/service/router.ts b/plugins/app-backend/src/service/router.ts index f58091f762..86736d832e 100644 --- a/plugins/app-backend/src/service/router.ts +++ b/plugins/app-backend/src/service/router.ts @@ -257,20 +257,23 @@ async function injectAppMode(options: { rootDir: string; }) { const { appMode, rootDir } = options; - const originalIndexHtmlContent = await fs.readFile( - resolvePath(rootDir, 'index.html'), - 'utf8', - ); - if (originalIndexHtmlContent.includes('backstage-app-mode')) return; - const modifiedIndexHtmlContent = originalIndexHtmlContent.replace( - /
/, - ``, - ); - await fs.writeFile( - resolvePath(rootDir, 'index.html'), - modifiedIndexHtmlContent, - 'utf8', - ); + const content = await fs.readFile(resolvePath(rootDir, 'index.html'), 'utf8'); + + const metaTag = ``; + + let newContent; + if (content.includes('backstage-app-mode')) { + console.log(`DEBUG: REPLACE`, metaTag); + newContent = content.replace( + //, + metaTag, + ); + console.log(`DEBUG: newContent=`, newContent); + } else { + newContent = content.replace(//, `${metaTag}`); + } + + await fs.writeFile(resolvePath(rootDir, 'index.html'), newContent, 'utf8'); } async function createEntryPointRouter({