This commit is contained in:
parent
34a9c068c5
commit
8bc15951e4
1 changed files with 4 additions and 1 deletions
|
|
@ -587,11 +587,14 @@ function fmtKcal(n) {
|
||||||
return n.toLocaleString();
|
return n.toLocaleString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Base path detection (works under /caltrack/ or /)
|
||||||
|
const basePath = window.location.pathname.replace(/\/$/, '');
|
||||||
|
|
||||||
// Fetch helpers
|
// Fetch helpers
|
||||||
async function api(method, path, body) {
|
async function api(method, path, body) {
|
||||||
const opts = { method, headers: { 'Content-Type': 'application/json' } };
|
const opts = { method, headers: { 'Content-Type': 'application/json' } };
|
||||||
if (body) opts.body = JSON.stringify(body);
|
if (body) opts.body = JSON.stringify(body);
|
||||||
const res = await fetch(path, opts);
|
const res = await fetch(basePath + path, opts);
|
||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue