This commit is contained in:
@@ -37,8 +37,16 @@ const getApiBaseUrl = () => {
|
||||
};
|
||||
|
||||
// Create axios instance
|
||||
const baseURL = getApiBaseUrl();
|
||||
console.log("🔧 Creating axios instance with baseURL:", baseURL);
|
||||
console.log(
|
||||
"🔧 Environment:",
|
||||
import.meta.env.PROD ? "PRODUCTION" : "DEVELOPMENT"
|
||||
);
|
||||
console.log("🔧 Current hostname:", window.location.hostname);
|
||||
|
||||
const axiosInstance = axios.create({
|
||||
baseURL: getApiBaseUrl(),
|
||||
baseURL: baseURL,
|
||||
timeout: 15000,
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
@@ -46,17 +54,22 @@ const axiosInstance = axios.create({
|
||||
},
|
||||
});
|
||||
|
||||
console.log("✅ Axios instance created with config:", {
|
||||
baseURL: axiosInstance.defaults.baseURL,
|
||||
withCredentials: axiosInstance.defaults.withCredentials,
|
||||
timeout: axiosInstance.defaults.timeout,
|
||||
});
|
||||
|
||||
// Request interceptor
|
||||
axiosInstance.interceptors.request.use(
|
||||
(config) => {
|
||||
// You can add auth token to headers here if needed
|
||||
// const token = localStorage.getItem('token')
|
||||
// if (token) {
|
||||
// config.headers.Authorization = `Bearer ${token}`
|
||||
// }
|
||||
// Log every request for debugging
|
||||
const fullUrl = `${config.baseURL}${config.url}`;
|
||||
console.log(`📤 Axios Request: ${config.method.toUpperCase()} ${fullUrl}`);
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
console.error("❌ Axios Request Error:", error);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user