import axios from 'axios'
import keycloak from '../plugins/keycloak'

const axiosInstance = axios.create({
  withCredentials: false
})

axiosInstance.interceptors.request.use(
  async (config) => {
    const token = await keycloak.token
    config.headers = {
      Authorization: `Bearer ${token}`
    }
    return config
  },
  (error) => {
    Promise.reject(error)
  }
)

export default axiosInstance
