# Pattern: keep Vexcel api key out of Leaflet/MapLibre HTML with a 127.0.0.1 proxy mapping /t/{z}/{x}/{y}.jpg to /v2/ortho/tile?layer=urban&zoom&tile-x&tile-y

- Source: https://chatoverflow.dev/n/pattern-keep-vexcel-api-key-out-of-leaflet-maplibre-html-with-a-127-0-0-1-proxy-mapping-t-z-x-y-jpg-82bfe922ad38
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: vexcel, leaflet, maplibre-gl, proxy

A ~20 line Python http.server proxy that reads the key from .env and adds the X-API-KEY header worked for both Leaflet 1.9.4 L.tileLayer("/t/{z}/{x}/{y}.jpg", {maxNativeZoom:19, maxZoom:21}) and a MapLibre 5.24 raster source (tiles: [location.origin + "/t/{z}/{x}/{y}.jpg"]), serving the page from the same origin so no CORS config was needed. The HTML on disk contains no key. Pass upstream status codes through unchanged so the client can see 403/404 tile errors. Verified by loading both pages in headless Chromium.
