From 89940b105fc31c2b246f6a82f3aea10b80b439ab Mon Sep 17 00:00:00 2001 From: Doxa Maps Date: Mon, 28 Sep 2026 21:52:20 +0000 Subject: [PATCH] EMBED_BASE_URL overrides the committed embedBaseUrl for a host's own tree build A host that builds its own tree (maps-dev's /cdn build inherits the container env) can bake absolute embed snippet URLs without a committed config change, the same pattern as DOXA_SYNC_PATHS. The value is the base without the tree name; a trailing slash is trimmed. check-embed-targets-exist reads the same effective base. Unset, the tree is byte-identical. --- internal/check-embed-targets-exist.mjs | 3 ++- internal/generate-tree.mjs | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/check-embed-targets-exist.mjs b/internal/check-embed-targets-exist.mjs index d48a94050..ef9328e0d 100644 --- a/internal/check-embed-targets-exist.mjs +++ b/internal/check-embed-targets-exist.mjs @@ -63,7 +63,8 @@ function collectIframeSrcs(manifest) { function resolveSrc(src) { const noQuery = src.split('?')[0].split('#')[0] if (/^(https?:)?\/\//i.test(noQuery)) { - const base = CFG.embedBaseUrl || '' + // The same effective base generate-tree bakes: EMBED_BASE_URL wins over the committed config. + const base = ((process.env.EMBED_BASE_URL || '').trim() || CFG.embedBaseUrl || '').replace(/\/+$/, '') if (!base || !noQuery.startsWith(base)) return { kind: 'skip', reason: 'off-site absolute URL' } let rest = noQuery.slice(base.length).replace(/^\/+/, '') if (rest.startsWith(TREE + '/')) rest = rest.slice(TREE.length + 1) diff --git a/internal/generate-tree.mjs b/internal/generate-tree.mjs index 1630bb043..70031aa93 100644 --- a/internal/generate-tree.mjs +++ b/internal/generate-tree.mjs @@ -73,7 +73,12 @@ function readBuildConfig() { if (!paths.includes(p)) paths.push(p) } } - const embedBaseUrl = (typeof cfg.embedBaseUrl === 'string' ? cfg.embedBaseUrl.trim() : '').replace(/\/+$/, '') + // EMBED_BASE_URL overrides the committed embedBaseUrl, the same way DOXA_SYNC_PATHS extends paths: + // a host that builds its own tree (maps-dev's /cdn build inherits the container env) bakes absolute + // snippet URLs without a committed config change. It is the base WITHOUT the tree name + // (https://maps-dev.nuxtbase.app/cdn -> .../cdn//...). check-embed-targets-exist reads the same. + const embedBaseUrl = ((process.env.EMBED_BASE_URL || '').trim() + || (typeof cfg.embedBaseUrl === 'string' ? cfg.embedBaseUrl.trim() : '')).replace(/\/+$/, '') const tokenUrl = typeof cfg.tokenUrl === 'string' ? cfg.tokenUrl.trim() : '' // OPT-IN baked token (token ladder rung 3): a literal Mapbox token inlined into // every generated page. Empty by default — prefer tokenUrl (a URL, not a secret).