refactor : restructure types

This commit is contained in:
2026-03-18 17:09:58 +05:30
parent f35389ab69
commit 7f8854ed78
31 changed files with 629 additions and 259 deletions

View File

@@ -0,0 +1,44 @@
import { ENV_CONSTANT } from "@/constants/secrect.constant";
import axios from "axios";
const BASE_URL = ENV_CONSTANT.BASE_API_URL;
const axiosClient = axios.create({
baseURL: BASE_URL,
headers: {
// "Content-Type": "application/json",
"ngrok-skip-browser-warning": "true"
},
});
// Add request interceptor to inject access token
axiosClient.interceptors.request.use(
(config) => {
if (typeof window !== "undefined") {
const token = localStorage.getItem("token");
if (token && config.headers) {
config.headers["Authorization"] = `Bearer ${token}`;
}
}
return config;
},
(error) => {
return Promise.reject(error);
}
);
// Basic response interceptor
axiosClient.interceptors.response.use(
(response) => response,
(error) => {
// Standard error handling can be added here later
return Promise.reject(error);
}
);
export const axiosAuth = axios.create({
baseURL: BASE_URL,
headers: { "Content-Type": "application/json" },
});
export default axiosClient;