import axios from 'axios';

// Use same-origin proxy
// No baseURL prefix needed because next.config.mjs now proxies '/api/:path*' directly
const API_BASE_URL = '';

export const apiClient = axios.create({
  baseURL: API_BASE_URL,
  headers: {
    'Content-Type': 'application/json',
  },
  timeout: 10000,
});

apiClient.interceptors.response.use(
  (response) => response,
  (error) => {
    // Only log essential info to avoid clutter
    console.error('[API ERROR]', {
      path: error.config?.url,
      message: error.message,
      status: error.response?.status
    });
    return Promise.reject(error);
  }
);
