This commit is contained in:
2026-05-02 17:04:37 +02:00
parent b0509818b2
commit e12b48b3e1
2 changed files with 21 additions and 3 deletions

View File

@@ -0,0 +1,20 @@
// composables/useApi.js
import axios from 'axios';
export const useApi = () => {
const config = useRuntimeConfig();
const server = axios.create({
baseURL: config.public.apiBaseUrl,
});
server.interceptors.request.use((cfg) => {
const token = localStorage.getItem('token');
if (token) {
cfg.headers.Authorization = `Bearer ${token}`;
}
return cfg;
});
return server;
};