Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/islands/maps/MapExplorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,19 @@ export default function MapExplorer({ lang = 'en' }: { lang?: Lang }) {
// never needs its own TileJSON fetch (avoids stale CDN edge responses).
const styleInput = await fetchResolvedStyle(initialUrl);
if (cancelled || !containerRef.current) return;
// Rewrite every OpenFreeMap URL that MapLibre would fetch on its own
// (TileJSON, vector/raster tiles, glyphs, sprites) through our /ofm/ proxy.
// This is the definitive safety net: even if fetchResolvedStyle leaves a
// raw OFM url in the source config, transformRequest rewrites it before
// any network request is dispatched — including requests from tile workers.
const OFM_ORIGIN = 'https://tiles.openfreemap.org/';
const ofmProxyBase = `${location.origin}/ofm/`;
const transformRequest = (url: string) => {
if (url.startsWith(OFM_ORIGIN)) {
return { url: ofmProxyBase + url.slice(OFM_ORIGIN.length) };
}
};

const map = new ml.Map({
container: containerRef.current,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -200,6 +213,7 @@ export default function MapExplorer({ lang = 'en' }: { lang?: Lang }) {
zoom: 3,
minZoom: 0,
maxZoom: 20,
transformRequest,
});
map.addControl(new ml.NavigationControl(), 'top-right');
// Cap GeolocateControl zoom at 14 — the vector tile source's maxzoom is 14;
Expand Down
Loading