diff --git a/web/index.html b/web/index.html
index 62f5df9..f0a4231 100644
--- a/web/index.html
+++ b/web/index.html
@@ -587,11 +587,14 @@ function fmtKcal(n) {
return n.toLocaleString();
}
+// Base path detection (works under /caltrack/ or /)
+const basePath = window.location.pathname.replace(/\/$/, '');
+
// Fetch helpers
async function api(method, path, body) {
const opts = { method, headers: { 'Content-Type': 'application/json' } };
if (body) opts.body = JSON.stringify(body);
- const res = await fetch(path, opts);
+ const res = await fetch(basePath + path, opts);
return res.json();
}