From d4daff02b91710c5bb166b2a4bdef9c0ec626b46 Mon Sep 17 00:00:00 2001 From: doxa-maps Date: Mon, 28 Sep 2026 03:58:13 +0000 Subject: [PATCH] Research page: NUXT_PUBLIC_DX_MAPS_BASE loads the dx-maps tree from a maps CDN Set, the gallery script and its tree-base come from that URL (e.g. https://maps-dev.nuxtbase.app/cdn/dx-maps). Unset, the page uses this site's own /dx-maps/ copy exactly as before. Both modes proven on the dev server: 0 console errors, the gallery tabs draw, and every dx-maps request goes to the chosen host. --- .env.example | 4 ++++ DX-MAPS-GALLERY.md | 8 ++++++++ app/pages/research/index.vue | 13 ++++++++----- nuxt.config.ts | 3 +++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index 2db5ded7..8349e38b 100644 --- a/.env.example +++ b/.env.example @@ -37,6 +37,10 @@ MOBILE_APP_ANDROID_PACKAGE=life.doxa.pray # Mapbox (used by the prayer map on /pray) NUXT_PUBLIC_MAPBOX_TOKEN=your-mapbox-public-token +# Research page: load the dx-maps tree from a maps CDN instead of this site's public/dx-maps copy. +# Unset = the local copy. The CDN must send Access-Control-Allow-Origin for the tree. +# NUXT_PUBLIC_DX_MAPS_BASE=https://maps-dev.nuxtbase.app/cdn/dx-maps + # Cloudflare Turnstile NUXT_TURNSTILE_SITE_KEY=your-turnstile-site-key NUXT_TURNSTILE_SECRET_KEY=your-turnstile-secret-key diff --git a/DX-MAPS-GALLERY.md b/DX-MAPS-GALLERY.md index 4224b225..a5f00c29 100644 --- a/DX-MAPS-GALLERY.md +++ b/DX-MAPS-GALLERY.md @@ -52,6 +52,14 @@ or `.env` is needed for this page. Without `DATABASE_URL`, the dev server only l `regions-dashboard`, `upg-100`, and so on). - Share and embed links in the maps point at this site's own `/dx-maps/` pages. +## Maps from a CDN instead of the local copy + +Set `NUXT_PUBLIC_DX_MAPS_BASE` to a dx-maps tree URL, for example +`NUXT_PUBLIC_DX_MAPS_BASE=https://maps-dev.nuxtbase.app/cdn/dx-maps`. The Research page then loads the +gallery script and every map from there. That host must send `Access-Control-Allow-Origin` for the tree. +Unset (the default), the page uses this site's own `public/dx-maps/` copy, as above. The home, pray and adopt +maps still load from the local copy. + ## Updating the maps Replace `public/dx-maps/` with a newer build of the tree, from the doxa-maps repo's diff --git a/app/pages/research/index.vue b/app/pages/research/index.vue index 58835641..539b7579 100644 --- a/app/pages/research/index.vue +++ b/app/pages/research/index.vue @@ -35,7 +35,10 @@ const researchProfileConfig = computed(() => JSON.stringify({ })) if (SHOW_LEGACY_RESEARCH) useTextHighlight() -const GALLERY_SCRIPT = '/dx-maps/doxa-maps-spa/doxa-maps-spa.js' +// The dx-maps tree: NUXT_PUBLIC_DX_MAPS_BASE when set (a maps CDN), otherwise this site's own +// /dx-maps/ copy. The script and every embed URL come from the same tree. +const DX_MAPS_BASE = ((runtimeConfig.public as { dxMapsBase?: string }).dxMapsBase || '').replace(/\/+$/, '') +const GALLERY_SCRIPT = `${DX_MAPS_BASE || '/dx-maps'}/doxa-maps-spa/doxa-maps-spa.js` useHead({ title: () => t('Research'), @@ -63,10 +66,10 @@ onMounted(() => { } gallery = document.createElement('doxa-maps-spa') - // Every embed URL is built at RUNTIME from the origin serving this page: the gallery reads its - // manifest and every child map from here, so the same build works on any host (laptop, staging, - // production) with nothing hardcoded. - gallery.setAttribute('tree-base', `${window.location.origin}/dx-maps`) + // Every embed URL is built at RUNTIME: from NUXT_PUBLIC_DX_MAPS_BASE when set, otherwise from the + // origin serving this page, so the same build works on any host (laptop, staging, production) with + // nothing hardcoded. + gallery.setAttribute('tree-base', DX_MAPS_BASE || `${window.location.origin}/dx-maps`) // The site's language drives the gallery's (and every map's); it follows the language switcher. gallery.setAttribute('language', locale.value) // With a Mapbox token configured, the maps use it. Without one (a fresh laptop), they use the diff --git a/nuxt.config.ts b/nuxt.config.ts index 2deaa7be..9a85a8ff 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -286,6 +286,9 @@ export default defineNuxtConfig({ siteUrl: process.env.NUXT_PUBLIC_SITE_URL || '', prayBaseUrl: process.env.NUXT_PUBLIC_PRAY_BASE_URL || 'https://pray.doxa.life', mapboxToken: process.env.NUXT_PUBLIC_MAPBOX_TOKEN || '', + // Where the Research page loads the dx-maps tree from (e.g. https://maps-dev.nuxtbase.app/cdn/dx-maps). + // Unset: this site's own /dx-maps/ copy (public/dx-maps). A foreign host must send CORS for the tree. + dxMapsBase: process.env.NUXT_PUBLIC_DX_MAPS_BASE || '', statinatorUrl: process.env.NUXT_PUBLIC_STATINATOR_URL || 'https://statinator.doxa.life', statinatorProjectId: process.env.NUXT_PUBLIC_STATINATOR_PROJECT_ID || 'doxa', statinatorEnabled: process.env.NUXT_PUBLIC_STATINATOR_ENABLED === 'true',