From 0e694dc2eab3e90b6abc2f8a1d25a3bd46b2a0f6 Mon Sep 17 00:00:00 2001 From: Coracle-Bot Date: Mon, 28 Sep 2026 23:35:51 +0000 Subject: [PATCH] Use a localhost CARTO key on the native apps and the dev server --- .env | 1 + README.md | 1 + src/app/components/SpaceMemberMap.svelte | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.env b/.env index c15267e8..6028f78b 100644 --- a/.env +++ b/.env @@ -23,6 +23,7 @@ VITE_DEFAULT_MESSAGING_RELAYS=auth.nostr1.com,relay.keychat.io,relay.ditto.pub VITE_SIGNER_RELAYS=ephemeral.snowflare.cc,bucket.coracle.social VITE_THUMBNAIL_URL=https://vthumbs.coracle.social VITE_CARTO_BASEMAP_KEY=cb1_42g1_1_7234813dd26909cd44b1dbe8 +VITE_CARTO_BASEMAP_KEY_LOCALHOST=cb1_42g1_3_bb09b0b53486b8f945a77a82 VITE_GLITCHTIP_API_KEY= GLITCHTIP_AUTH_TOKEN= VITE_HOSTING_BACKEND_URL=https://api.hosting.coracle.social diff --git a/README.md b/README.md index 43bbe0da..29dae05c 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ Create an `.env.local` file to override any of the values in `.env`: - `VITE_POMADE_SIGNERS` - A comma-separated list of Pomade signer server URLs (3+ required to enable email signup) - `VITE_THUMBNAIL_URL` - URL of the image thumbnail service - `VITE_CARTO_BASEMAP_KEY` - A CARTO Basemaps key for the member map's tiles, free from https://carto.com/basemaps/apikey/. Without one the tiles carry an "API key required" watermark. +- `VITE_CARTO_BASEMAP_KEY_LOCALHOST` - The CARTO key for the native apps and the dev server, which both serve from `localhost`. CARTO authorizes a key against a list of domains and refuses `localhost` on one that also names a real domain, so this is a second key. These values **won't** be used for a built version. Instead, env variables should be provided to `scripts/build/app.sh` directly or to the built container. diff --git a/src/app/components/SpaceMemberMap.svelte b/src/app/components/SpaceMemberMap.svelte index 1e38c63a..af646e32 100644 --- a/src/app/components/SpaceMemberMap.svelte +++ b/src/app/components/SpaceMemberMap.svelte @@ -19,6 +19,12 @@ const basemap = $derived($activeTheme === "dark" ? "dark_all" : "light_all") + // CARTO authorizes a key per referer, and the native apps and the dev server both serve from localhost. + const basemapKey = + location.hostname === "localhost" + ? import.meta.env.VITE_CARTO_BASEMAP_KEY_LOCALHOST + : import.meta.env.VITE_CARTO_BASEMAP_KEY + const openProfile = (pubkey: string) => pushModal(ProfileDetail, {pubkey, url}) let element: HTMLElement @@ -44,7 +50,7 @@ if (leaflet && map) { tile = leaflet .tileLayer( - `https://basemaps.cartocdn.com/rastertiles/${basemap}/{z}/{x}/{y}.png?key=${import.meta.env.VITE_CARTO_BASEMAP_KEY}`, + `https://basemaps.cartocdn.com/rastertiles/${basemap}/{z}/{x}/{y}.png?key=${basemapKey}`, { maxZoom: 12, attribution: