mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Configure baseUrl option for axios only once
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import Vue from 'vue'
|
||||
import axios from 'axios'
|
||||
import Cookies from 'js-cookie'
|
||||
|
||||
@@ -10,7 +9,6 @@ const _axios = axios.create()
|
||||
_axios.interceptors.request.use(
|
||||
function (config) {
|
||||
// Do something before request is sent
|
||||
config.baseURL = Vue.prototype.$config.API_BASE_URL
|
||||
if (store.state.auth.isAuthenticated) {
|
||||
config.headers['Accept-Language'] = store.state.auth.authUser.language
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import router from './router'
|
||||
import store from './store'
|
||||
import vuetify from './plugins/vuetify'
|
||||
import sassStyles from './styles/global.scss' // eslint-disable-line no-unused-vars
|
||||
import repository from './api/repository'
|
||||
|
||||
Vue.config.productionTip = false
|
||||
|
||||
@@ -15,7 +16,13 @@ export const bus = new Vue()
|
||||
|
||||
fetch(process.env.BASE_URL + 'config.json').then(resp => {
|
||||
resp.json().then((config) => {
|
||||
if (!config.API_BASE_URL) {
|
||||
throw Error('API_BASE_URL is not defined in config.json')
|
||||
}
|
||||
repository.defaults.baseURL = config.API_BASE_URL
|
||||
|
||||
Vue.prototype.$config = config
|
||||
|
||||
new Vue({
|
||||
router,
|
||||
store,
|
||||
|
||||
Reference in New Issue
Block a user