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.
This commit is contained in:
Doxa Maps 2026-09-28 21:52:20 +00:00
parent 91eabff50b
commit 89940b105f
2 changed files with 8 additions and 2 deletions

View file

@ -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)

View file

@ -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/<name>/...). 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).