fix auth and backend force

This commit is contained in:
Mateusz Gruszczyński
2026-07-26 16:06:30 +02:00
parent f145c3c121
commit 9b89ef79c4
6 changed files with 84 additions and 8 deletions
+2
View File
@@ -48,6 +48,8 @@ export async function api(path, options = {}) {
const timeout = setTimeout(() => controller.abort(), 12000);
try {
const headers = new Headers(options.headers || {});
const authToken = localStorage.getItem("rustpad:auth-token") || sessionStorage.getItem("rustpad:auth-token");
if (authToken && !headers.has("authorization")) headers.set("authorization", `Bearer ${authToken}`);
if (!(options.body instanceof FormData) && !headers.has("content-type")) headers.set("content-type", "application/json");
const started = performance.now();
logDebug("api.request", { method: options.method || "GET", path });