Add 'frontend/' from commit 'c070c0315d66a44154ab7d9f9ea6c211a15f4dba'

git-subtree-dir: frontend
git-subtree-mainline: 205a3bd14b
git-subtree-split: c070c0315d
This commit is contained in:
2025-01-15 15:24:17 -05:00
318 changed files with 29301 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import axios from "axios"
import {useAuthStore} from "@/stores/authStore.js"
export function useClient() {
if (!import.meta.env.VITE_API_URL) throw new Error("VITE_API_URL is not provided")
const api = axios.create({
baseURL: import.meta.env.VITE_API_URL,
timeout: 10000,
});
const authStore = useAuthStore()
const requestInterceptor = (config) => {
if (authStore.isAuthenticated) {
config.headers["Authorization"] = `Bearer ${authStore.accessToken}`
}
return config
}
api.interceptors.request.use(requestInterceptor);
return api;
}