This commit is contained in:
@@ -1,20 +0,0 @@
|
|||||||
// 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;
|
|
||||||
};
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
const backendUrl = process.env.API_BASE_URL || 'http://localhost:5000/api'
|
const backendUrl = import.meta.env.API_BASE_URL || 'http://localhost:5000/api'
|
||||||
|
|
||||||
export {
|
export {
|
||||||
backendUrl
|
backendUrl
|
||||||
|
|||||||
Reference in New Issue
Block a user