Skip to content

Serve the basemap from our own tile server, with CARTO's Dark Matter style - #516

Merged
simplifaisoul merged 5 commits into
masterfrom
feat/self-hosted-basemap
Nov 25, 2026
Merged

simplifaisoul merged 5 commits into
masterfrom
feat/self-hosted-basemap

Conversation

@simplifaisoul

Copy link
Copy Markdown
Owner

Summary

CARTO now refuses osirisai.live both through the tile proxy (403) and in the browser (no CORS header). The proxy's long-cached style also points at a tile version CARTO has retired. The result is a blank or patchy MAP view and a stream of tile errors in the console.

This serves the basemap from our own tile server instead. It uses the Protomaps OpenStreetMap world map, which is the same schema CARTO's own vector tiles have used since 21 October, drawn with a copy of CARTO's Dark Matter style, so the map looks the same as before. Tiles that our tile server can't deliver fall back to CARTO copies still held in the tile proxy's caches.

It also updates Next.js to 16.4.6. On 16.4.3, next build stops on a known-vulnerability check, which blocks every production build.

Changes

  • /api/basemap: serves the style and relays tiles, label fonts and the icon sheet from the tile server set in BASEMAP_URL (tileset named by BASEMAP_TILESET).
    • Tile URLs carry the tileset name, so tiles are cached for a year (immutable). Fonts and icons are cached for 30 days, the style for an hour at the edge.
    • Responses avoid Next's fetch cache, which previously filled server disks with proxied tiles.
    • The style's zoom range follows what the tileset actually holds, so the map enlarges its deepest tiles instead of requesting missing ones.
    • Style URLs are built from the Host header only, so a forged forwarding header can't end up in the edge-cached style.
    • Without BASEMAP_URL, the style redirects to OpenFreeMap's Dark Matter, so self-hosted copies keep a working map with nothing to set up.
  • Style: src/lib/basemap/dark-matter.json is a copy of CARTO's current Dark Matter (Protomaps schema), which CARTO's basemap-styles README allows hosting. Its font stacks add Noto fallbacks for Arabic, Hebrew, Indic and other scripts. Attribution credits OpenStreetMap, CARTO and Protomaps.
  • Tile fallback: src/lib/basemap/tile-backup.ts, a MapLibre protocol. If our tile server errors, can't be reached, takes more than 5 s to start answering or cuts off, it requests the same tile of CARTO's Dark Matter through /api/proxy-tiles. That tile uses the same schema and draws in the same style. Only copies already in the proxy's caches can answer.
  • Map labels use Noto Sans (served by both the tile server and OpenFreeMap) instead of Open Sans. Clouds and rain sit under the place-name labels rather than the first label layer.
  • Removed src/lib/carto-fallback.ts, which the new loader replaces.
  • Privacy page: map tiles now come from OSIRIS's own map server.
  • .env.example documents BASEMAP_URL and BASEMAP_TILESET.
  • Dependencies: next and eslint-config-next 16.4.3 → 16.4.6.

Deployment

Set on each app server, pointing at a Martin tile server on the private network that holds a Protomaps .pmtiles world map, the label fonts and the icon sheet:

BASEMAP_URL=http://<tile-server>:<port>
BASEMAP_TILESET=<pmtiles file name without extension>

The existing Cloudflare cache rule for /api/* covers the new route. Removing BASEMAP_URL and restarting the app returns the map to OpenFreeMap without a rebuild.

Testing

  • npx vitest run: 179 files and 1,820 tests pass (27 skipped, as on master), including 22 new route tests and 10 new fallback tests.
  • npx tsc --noEmit: no errors. ESLint: no new findings in changed files.
  • next build on 16.4.6: completes with exit code 0.
  • Production build exercised in headless Chrome against a Martin tile server:
    • Globe, Europe, Middle East, London, Los Angeles and New York views, at zooms up to 15.5.
    • All style, font, icon and tile requests answered 200, with none to third-party map hosts.
    • With the tile route blocked, the map switched to the CARTO fallback for each tile.

🤖 Generated with SIMPLIFAI

Gemini CLI added 5 commits November 25, 2026 16:53
CARTO now refuses osirisai.live both through the tile proxy (403) and in
the browser (no CORS header), and the proxy's year-long cached style still
pointed at a tile version CARTO has retired, so the MAP view went blank.

- Load OpenFreeMap's keyless Dark Matter style straight from the browser
- Remove the CARTO proxy-or-direct loader, which nothing uses any more
- Use Noto Sans for OSIRIS's own map labels; OpenFreeMap serves no Open
  Sans and no combined font stacks
- Keep clouds and rain under the place names rather than the first label,
  since OpenFreeMap draws water names below its roads and borders
- Credit OpenFreeMap instead of CARTO on the privacy page
CARTO refuses osirisai.live, so the basemap now comes from a Martin tile
server on a private network, holding the Protomaps OpenStreetMap world map
that CARTO's own vector tiles are built from.

- Add /api/basemap: the style, tiles, merged label fonts and icon sheet,
  relayed from BASEMAP_URL with year-long caching for versioned tiles and
  no Next fetch cache
- Ship a copy of CARTO's current Dark Matter style (Protomaps schema), with
  Noto fallbacks for Arabic, Hebrew, Indic and other scripts
- Build the style's URLs from the Host header only, so a forged forwarded
  header cannot end up in the edge-cached style
- Fall back to OpenFreeMap's Dark Matter when no tile server is configured
- Document BASEMAP_URL and BASEMAP_TILESET in .env.example
Past the deepest zoom the tile server has, the map now enlarges those tiles
instead of asking for ones that don't exist, which showed as 404s and a
blank map when zoomed into a city.
…'t deliver

Basemap tiles load through a MapLibre protocol that asks /api/basemap first
and, if it errors, can't be reached, stalls past 5 s or cuts off, asks the
CARTO tile proxy for the same tile of CARTO's Dark Matter. CARTO's tiles use
the same Protomaps schema, so they draw in the same style; only copies the
proxy's caches still hold can answer.
next build on 16.4.3 stops with a known-vulnerability check, which blocks
every production build.
@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
osiris Ready Ready Preview Nov 25, 2026 10:02pm UTC

This branch was successfully deployed

1 active deployment
Preview – osiris — 1872d18a Deployed Nov 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant