JuanCS-Dev's picture
fix(deploy): fix 403 Forbidden and AttributeError in dashboard
89b6a21
Raw History Blame Contribute Delete
843 Bytes
import { fetchWithTimeout } from "../shared/api.js";
import { getStorageItem } from "../shared/dom.js";
const TOKEN_KEY = "byte_dashboard_admin_token";
const AUTONOMY_TICK_ENDPOINT = "./api/autonomy/tick";
const REQUEST_TIMEOUT_MS = 15000;
function authHeaders() {
const headers = {};
const token = getStorageItem(TOKEN_KEY);
if (token) {
headers["X-Byte-Admin-Token"] = token;
}
return headers;
}
export async function triggerAutonomyTick({ force = true, reason = "manual_dashboard" } = {}, timeoutMs = REQUEST_TIMEOUT_MS) {
return await fetchWithTimeout(
AUTONOMY_TICK_ENDPOINT,
{
method: "POST",
headers: authHeaders(),
body: JSON.stringify({ force: Boolean(force), reason: String(reason || "manual_dashboard") }),
},
timeoutMs
);
}