import axios from 'axios'; const baseURL = typeof window !== 'undefined' ? '/api' : (process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3000/api'); const api = axios.create({ baseURL, timeout: 10000, headers: { 'Content-Type': 'application/json', }, }); // Interceptor to add auth token in the future api.interceptors.request.use( (config) => { let token = null; if (typeof window !== 'undefined') { token = localStorage.getItem('accessToken'); } if (token && config.headers) { config.headers.Authorization = `Bearer ${token}`; } return config; }, (error) => Promise.reject(error) ); export default api;