import { boot } from 'quasar/wrappers'
import axios from 'axios'

export const api = axios.create({
  baseURL: 'http://localhost:8080/api',
  timeout: 180000,
  withCredentials: true // refresh cookie kullanıyorsan kalsın
})

export default boot(() => {
  api.interceptors.request.use((config) => {
    const token = localStorage.getItem('token') // ✅ senin authStore key’in

    if (token) {
      config.headers = config.headers || {}
      config.headers.Authorization = `Bearer ${token}`
    }

    return config
  })
})
