This repository has been archived on 2026-10-05. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
dnd-manager/frontend/src/api/client.ts
T
2026-09-22 16:27:53 +02:00

20 lines
574 B
TypeScript

import axios from 'axios';
export const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:4000';
export const apiClient = axios.create({ baseURL: API_URL });
export function setAuthToken(token: string | null) {
if (token) {
apiClient.defaults.headers.common.Authorization = `Bearer ${token}`;
localStorage.setItem('dnd_token', token);
} else {
delete apiClient.defaults.headers.common.Authorization;
localStorage.removeItem('dnd_token');
}
}
export function getStoredToken(): string | null {
return localStorage.getItem('dnd_token');
}