set up for deployment

This commit is contained in:
M1ngdaXie
2026-01-12 00:16:55 -08:00
parent 6b1ed8d11c
commit 819760662a
26 changed files with 568 additions and 13 deletions

View File

@@ -3,11 +3,18 @@ const API_BASE_URL = import.meta.env.VITE_API_URL || "http://localhost:8080/api"
export async function authFetch(url: string, options?: RequestInit): Promise<Response> {
const token = localStorage.getItem('auth_token');
const headers: HeadersInit = {
const headers: Record<string, string> = {
'Content-Type': 'application/json',
...options?.headers,
};
// Merge existing headers if provided
if (options?.headers) {
const existingHeaders = new Headers(options.headers);
existingHeaders.forEach((value, key) => {
headers[key] = value;
});
}
// Add Authorization header if token exists
if (token) {
headers['Authorization'] = `Bearer ${token}`;