diff --git a/tasks/enduro-trails/prototype/static/app.js b/tasks/enduro-trails/prototype/static/app.js index 24db73e..0451be0 100644 --- a/tasks/enduro-trails/prototype/static/app.js +++ b/tasks/enduro-trails/prototype/static/app.js @@ -86,8 +86,10 @@ function toggleLayer(group) { // ─── Map init ───────────────────────────────────────────────────────────────── async function initMap() { - const tileBase = window.location.origin; - const style = await fetch('/style.json').then(r => r.json()); + // Определяем base path для работы как на корне, так и под /enduro/ + const basePath = window.location.pathname.replace(/\/[^/]*$/, '') || ''; + const tileBase = window.location.origin + basePath; + const style = await fetch(basePath + '/style.json').then(r => r.json()); style.sources['trails-tiles'].tiles = [`${tileBase}/api/tiles/{z}/{x}/{y}.mvt`]; const map = new maplibregl.Map({ @@ -197,7 +199,7 @@ async function initMap() { async function checkDataAvailability() { try { - const resp = await fetch('/api/health'); + const resp = await fetch(basePath + '/api/health'); const data = await resp.json(); if (!data.db_exists) { document.getElementById('no-data-warning').classList.add('visible');