Skip to content

fix(maps): proxy OFM tiles through /ofm/ to fix blank map for SE Asia users - #172

Merged
slaveofcode merged 1 commit into
developfrom
fix/map-ofm-proxy
Aug 8, 2026
Merged

fix(maps): proxy OFM tiles through /ofm/ to fix blank map for SE Asia users#172
slaveofcode merged 1 commit into
developfrom
fix/map-ofm-proxy

Conversation

@slaveofcode

Copy link
Copy Markdown
Owner

Problem

Jakarta-region users see a blank Map Explorer after load / after GeolocateControl flyTo. Console shows [map] source loading: openmaptiles firing 68+ times but [map] source loaded: openmaptiles never appearing — tile requests are made but never complete.

Root cause: Cloudflare's Singapore CDN edge (which serves Jakarta) returns corrupt responses for tiles.openfreemap.org:

  • Style JSON sometimes returns a TypeScript schema (no version/sources) instead of valid JSON
  • PBF vector tile requests hang or return invalid content that MapLibre can't decode

Fix

Route all OpenFreeMap requests through our own Cloudflare Worker at /ofm/*. The Worker fetches from OFM's origin server-side over Cloudflare's backbone — bypassing the broken edge node. Cloudflare then serves the cached response from the nearest healthy PoP.

worker/index.js — new /ofm/* proxy route with CF edge caching

map-styles.lib.tsresolveStyle() returns /ofm/styles/<id> (same-origin)

MapExplorer.tsxfetchResolvedStyle() rewrites all OFM URLs through proxy:

  • Style JSON fetched via /ofm/styles/<name>
  • TileJSON fetched via /ofm/planet (was tiles.openfreemap.org/planet)
  • Tile URL template rewritten: /ofm/planet/TIMESTAMP/{z}/{x}/{y}.pbf
  • Glyph and sprite URLs also rewritten through proxy

Test

All 837 tests pass · lint 0 errors · build succeeds

🤖 Generated with Claude Code

…tiles

Cloudflare's Singapore CDN edge serves corrupt responses to Jakarta-region
users: style JSON returns a TypeScript schema and PBF tile requests never
complete. Routing every OFM request (style, TileJSON, glyphs, sprites, tiles)
through our own Cloudflare Worker at /ofm/* fetches from OFM's origin
server-side, bypassing the broken edge node entirely.

- worker/index.js: add /ofm/* proxy with CF edge caching (24h for
  style/TileJSON, immutable for versioned .pbf tiles)
- map-styles.lib.ts: resolveStyle() returns /ofm/styles/<id> instead of
  the absolute OFM URL
- MapExplorer.tsx: fetchResolvedStyle() rewrites all OFM URLs through the
  proxy (glyphs, sprites, raster tile arrays, vector TileJSON + tile URLs)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 8, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
goodwebtools a21a67d Aug 08 2026, 06:52 AM

@slaveofcode
slaveofcode merged commit db34a58 into develop Aug 8, 2026
1 of 2 checks passed
@slaveofcode
slaveofcode deleted the fix/map-ofm-proxy branch August 8, 2026 06:51
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