fix(maps): avoid 404 on keyless Google tiles-token probe (#1066)

Return an uncached unavailable-token response for keyless Google tile-token requests.

Contribution by @dvilrgamerz.
This commit is contained in:
Jenil Patel authored and GitHub committed 2026-10-25 19:13:38 -07:00
1 parent 06c51d3438
commit a7fcb3c232
8 files changed
+147 -4

No files matched your search

@@ -0,0 +1,27 @@
/**
* Treat an unavailable Google Maps tile-token endpoint as a supported, silent
* outcome. Install after real token providers and before the unknown-API 404.
*/
export function googleTokenUnavailablePlugin() {
const install = (server) => {
server.middlewares.use((req, res, next) => {
const pathname = String(req.url || '').split('?')[0];
if (
(req.method !== 'GET' && req.method !== 'HEAD') ||
pathname !== '/api/google/tiles-token'
) {
next();
return;
}
res.writeHead(204, { 'Cache-Control': 'no-store' });
res.end();
});
};
return {
name: 'google-token-unavailable',
configureServer: install,
configurePreviewServer: install,
};
}