pageUnder

tcmts.cli.web.pageUnder · #gkic36pt · term · runs anywhere

An app's page as served under base: its assets' URLs under it, and the base said to the page (__TCM_BASE__), so the runtime calls the server there and the react library reads and writes paths within it. The build itself doesn't know where it's served: one build serves any base.

export function pageUnder(html: string, base: string): string {
  if (!base) return html;
  return html
    .replaceAll('"/_app/', `"${base}/_app/`)
    .replace(/<head>/, `<head>\n<script>var __TCM_BASE__ = ${JSON.stringify(base)};</script>`);
}

used by