diff --git a/src/app/api/geoportal/monitor/route.ts b/src/app/api/geoportal/monitor/route.ts index 9d40dec..392259f 100644 --- a/src/app/api/geoportal/monitor/route.ts +++ b/src/app/api/geoportal/monitor/route.ts @@ -10,6 +10,10 @@ export const dynamic = "force-dynamic"; const TILE_CACHE_INTERNAL = "http://tile-cache:80"; const MARTIN_INTERNAL = "http://martin:3000"; const PMTILES_URL = process.env.NEXT_PUBLIC_PMTILES_URL || ""; +// Server-side fetch needs absolute URL — resolve relative paths through tile-cache +const PMTILES_FETCH_URL = PMTILES_URL.startsWith("/") + ? `${TILE_CACHE_INTERNAL}${PMTILES_URL.replace(/^\/tiles/, "")}` + : PMTILES_URL; const N8N_WEBHOOK_URL = process.env.N8N_WEBHOOK_URL || ""; type NginxStatus = { @@ -88,7 +92,7 @@ export async function GET() { // 3. PMTiles info if (PMTILES_URL) { try { - const res = await fetchWithTimeout(PMTILES_URL, 3000); + const res = await fetchWithTimeout(PMTILES_FETCH_URL, 3000); result.pmtiles = { url: PMTILES_URL, status: res.ok ? "ok" : `HTTP ${res.status}`, @@ -138,7 +142,7 @@ export async function GET() { async function getPmtilesInfo(): Promise<{ size: string; lastModified: string } | null> { if (!PMTILES_URL) return null; try { - const res = await fetchWithTimeout(PMTILES_URL, 3000); + const res = await fetchWithTimeout(PMTILES_FETCH_URL, 3000); return { size: res.headers.get("content-length") ? `${(parseInt(res.headers.get("content-length") ?? "0", 10) / 1024 / 1024).toFixed(1)} MB`