Files
gods-eye-view/server/standalone/google-token-unavailable.js
T
Jenil Patel a7fcb3c232 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.
2026-10-25 19:13:38 -07:00

28 lines
737 B
JavaScript

/**
* 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,
};
}