mirror of
https://github.com/Dvorinka/Primora.git
synced 2026-10-29 08:04:50 +00:00
initiall commit
This commit is contained in:
commit
7ddfb1f52b
276 files changed
+37629
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user