First merge from develop to main (WIP) #7

Merged
sugar merged 199 commits from develop into main 2026-01-27 17:47:07 +00:00
Showing only changes of commit 3e9656db23 - Show all commits

24
client/src/lib/axios.ts Normal file
View File

@@ -0,0 +1,24 @@
import type { AxiosError } from 'axios';
import axios from 'axios';
export const axiosClient = axios.create({
baseURL: '/api/',
});
axiosClient.interceptors.request.use((config) => {
const token = localStorage.getItem('token');
if (token !== null) {
config.headers.Authorization = `Bearer ${token}`;
}
return config;
});
axiosClient.interceptors.response.use(undefined, async (error: AxiosError) => {
if (error.response && error?.response.status === 401) {
// TODO: refresh token
if (error.config) {
return axiosClient(error.config);
}
}
return Promise.reject(error);
});