import axios from 'axios';

export const API_BASE_URL = import.meta.env.VITE_BASE_URL || 'http://localhost:8000';

const api = axios.create({ baseURL: API_BASE_URL });

// Add token to requests if available
api.interceptors.request.use((config) => {
  const token = localStorage.getItem('token');
  if (token) {
    config.headers.Authorization = `Bearer ${token}`;
  }
  return config;
});

export default api;
