Skip to content

fix(api): keep the MapTiler key out of every proxied JSON document - #992

Open
Medformatik wants to merge 1 commit into
fix/feed-proxy-redirect-targetsfrom
fix/maptiler-style-key-passthrough
Open

Medformatik wants to merge 1 commit into
fix/feed-proxy-redirect-targetsfrom
fix/maptiler-style-key-passthrough

Conversation

@Medformatik

@Medformatik Medformatik commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

The MapTiler proxy keeps the operator's API key on the server and serves style and tile documents publicly with a week of caching. MapTiler writes the caller's key into the URLs inside those documents. The proxy rewrote the fields it knew (glyphs, a string sprite, each source's url and tiles) and passed every other value through unchanged. A key-bearing URL in a field it did not visit, on a MapTiler path it does not proxy or on another MapTiler host would have been served to every visitor. No default style is known to do this today; the change makes the proxy fail closed.

Every JSON document the proxy serves (style, TileJSON and sprite JSON) now goes through one path: the known fields are rewritten as before, including the list form of sprite; the key parameter is removed from every remaining URL string on a MapTiler host, or on any host when its value is the configured key; and a document that still contains the key anywhere is refused with an uncached 502. A removal is logged with a count and no URL.

Related work

Fifth layer of the stack that starts with #983.

Verification

  • maptiler.test.ts passes (36 tests) with six new cases: list-form sprite, key removed from unknown fields with tile placeholders and other parameters kept, a non-MapTiler host, refusal when the key sits inside attribution HTML with nothing in the response or the logs, and sprite JSON with and without the key.
  • pnpm -C apps/api check-types and Biome pass on the touched files.
  • Not done: a fetch of real MapTiler documents and a rendered basemap.

Release and upgrade impact

No operator action and no migration.

@Medformatik Medformatik self-assigned this Nov 16, 2026
@Medformatik
Medformatik added this pull request to stack #985 November 16, 2026 09:14
@Medformatik
Medformatik force-pushed the fix/maptiler-style-key-passthrough branch from b78a677 to bb3d935 Compare November 16, 2026 10:00
The proxy rewrote only the style and TileJSON fields it knew and passed any
other URL through unchanged, key included. It now strips the key from every
URL string in style, TileJSON and sprite JSON, rewrites list-form sprites,
and refuses a document in which the key is still present.
@Medformatik
Medformatik force-pushed the fix/maptiler-style-key-passthrough branch from bb3d935 to aa12be1 Compare November 16, 2026 17:23
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