initial state

This commit is contained in:
2026-05-14 18:21:47 +02:00
commit f601558662
33 changed files with 4799 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
// src/lib/apiClient.ts
import axios from 'axios';
export const api = axios.create({
baseURL: '/api',
headers: { 'Content-Type': 'application/json' },
});
api.interceptors.request.use(config => {
const token = localStorage.getItem('token');
if (token) config.headers.Authorization = `Bearer ${token}`;
return config;
});
api.interceptors.response.use(
res => res,
async err => {
if (err.response?.status === 401) {
localStorage.removeItem('token');
window.location.href = '/login';
}
// @ts-ignore
return Promise.reject(err);
}
);