Merge pull request #5052 from ericscheid/defang-script-546

defang <script in json 546
This commit is contained in:
Víctor Losada Hernández
2026-09-25 10:48:40 +02:00
committed by GitHub
+6 -1
View File
@@ -280,9 +280,14 @@ export default async function createApp(vite) {
html = await vite.transformIndexHtml(req.originalUrl, html);
}
const safeProps = JSON.stringify(props).replace(/<(?=\/?script)/ig, '\\u003c');
html = html.replace(
'<head>',
()=>{ return `<head>\n<script id="props" >window.__INITIAL_PROPS__ = ${JSON.stringify(props)}</script>\n${ogMetaTags}`; }
`<head>\n`
+ `<script id="props">`
+ `window.__INITIAL_PROPS__ = ` + safeProps
+ `</script>\n`
+ ogMetaTags
);
return html;