import axios from "axios";
import tg, { STORAGE_KEYS } from "@/tg";

const api = axios.create({
  baseURL: import.meta.env.VITE_API_BASE_URL,
  headers: {
    ...(import.meta.env.DEV && {
      "ngrok-skip-browser-warning": "true",
    }),
  },
});

api.interceptors.request.use(async (config) => {
  config.headers.Authorization = `Bearer ${await tg.storage.getItem(STORAGE_KEYS.authToken)}`;
  return config;
});

export default api;
