fix(tiles): configure R2 CDN base URL build argument to resolve production basemap 404 #120
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What to build
Resolve the production 404 error when loading
indonesia.pmtilesby configuringNEXT_PUBLIC_TILES_BASE_URLin Docker image compilation and providing a production default fallback to Cloudflare R2.Root Cause
public/tiles/indonesia.pmtiles(81 MB) is deliberately gitignored to prevent committing large binary vector tile archives into git.https://tiles.gambut.nokopia.com/tiles/indonesia.pmtiles(HTTP 200 with byte-range request support).Dockerfileand.forgejo/workflows/deploy.yml,NEXT_PUBLIC_TILES_BASE_URLis neither declared as a Docker build argument nor supplied during the image build.""forNEXT_PUBLIC_TILES_BASE_URLduringpnpm build, causingresolveTileUrl()insrc/lib/gis/tile-url.tsto fall back topmtiles:///tiles/indonesia.pmtiles.public/tiles/indonesia.pmtiles, returning HTTP 404 when the client MapLibre instance attempts to fetch basemap tiles.Technical specifications
Dockerfile: DeclareARG NEXT_PUBLIC_TILES_BASE_URL=https://tiles.gambut.nokopia.com/tilesand pass it to thebuilderstage asENV NEXT_PUBLIC_TILES_BASE_URL=$NEXT_PUBLIC_TILES_BASE_URL..forgejo/workflows/deploy.yml: Addbuild-args: NEXT_PUBLIC_TILES_BASE_URL=https://tiles.gambut.nokopia.com/tilestodocker/build-push-action.src/lib/gis/tile-url.ts: In production environments (process.env.NODE_ENV === "production"), defaultbasetohttps://tiles.gambut.nokopia.com/tilesifNEXT_PUBLIC_TILES_BASE_URLis unset or empty, ensuring gitignored tile archives never fall back to the container in production.src/lib/gis/__tests__/tile-url.test.ts: Add test cases validating production fallback behavior and local development fallback isolation.Acceptance criteria
Dockerfileanddeploy.ymlaccept and passNEXT_PUBLIC_TILES_BASE_URL.resolveTileUrl("indonesia")resolves topmtiles://https://tiles.gambut.nokopia.com/tiles/indonesia.pmtileswhen built in production mode without explicit local overrides.pnpm dev) continues to resolve to localpmtiles:///tiles/...whenNEXT_PUBLIC_TILES_BASE_URLis not provided.Authoritative Specifications & Reference Documentation
docs/ARCHITECTURE.mdhttps://tiles.gambut.nokopia.com/tiles/indonesia.pmtilessrc/lib/gis/tile-url.ts