fix auth and backend force
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user