initiall commit

This commit is contained in:
Tomas Dvorak committed 2026-04-10 12:03:31 +02:00
commit 7ddfb1f52b
276 files changed
+37629

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
import { createAuthClient } from "better-auth/solid";
// Use full URL for dev mode, relative path for production
const baseURL = import.meta.env.VITE_AUTH_BASE_URL ?? "http://localhost/auth";
export const authClient = createAuthClient({
baseURL,
});
export async function fetchApiToken() {
const response = await fetch(`${baseURL}/token`, {
credentials: "include",
headers: {
accept: "application/json",
},
});
if (response.status === 401 || response.status === 403) {
return undefined;
}
if (!response.ok) {
throw new Error(`Failed to fetch API token (${response.status})`);
}
const data = (await response.json()) as { token: string };
return data.token;
}