import axios from 'axios';
import store from './store';

const apiClient = axios.create({
  baseURL: `${import.meta.env.VITE_BACKEND}/api`,
});

apiClient.interceptors.request.use(config => {
  const token = store.getters.token;
  const user = store.getters.username;

  if (token) {
    config.headers['authcode'] = token;
  }
  if (user) {
    config.headers['userid'] = user;
  }

  return config;
});

export default apiClient;
