axios.js 458 Bytes
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
import axios from 'axios'
import store from '~/store'
import Vue from 'vue'

// Request interceptor
axios.interceptors.request.use(request => {
request.baseURL = process.env.VUE_APP_BASE_URL

request.headers.Authorization = `Bearer ${Vue.prototype.$keycloak.token}`

const locale = store.getters['lang/locale']
if (locale) {
request.headers.common['Accept-Language'] = locale
}

return request
}, error => {
return Promise.reject(error)
})