Use a localhost CARTO key on the native apps and the dev server

This commit is contained in:
Coracle-Bot 2026-09-28 23:35:51 +00:00
parent 4da88c521d
commit 0e694dc2ea
3 changed files with 9 additions and 1 deletions

1
.env
View file

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

View file

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

View file

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