2025-09-19 17:20:05 -06:00
|
|
|
import axios from "axios";
|
|
|
|
|
import Cookies from "js-cookie";
|
|
|
|
|
import { envConfig } from "./config";
|
|
|
|
|
|
|
|
|
|
const apiClient = axios.create({
|
|
|
|
|
baseURL: envConfig.apiUrl,
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
apiClient.interceptors.request.use((config) => {
|
|
|
|
|
const token = Cookies.get("token");
|
|
|
|
|
if (token) {
|
|
|
|
|
if (config.headers && "set" in config.headers) {
|
|
|
|
|
config.headers.set("Authorization", `Bearer ${token}`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return config;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default apiClient;
|
2025-09-22 14:53:19 -06:00
|
|
|
//IO
|