Add axios auth interceptor

This commit is contained in:
Marcel Schwarz 2020-07-26 03:25:11 +02:00
parent 24240164ad
commit 5748cc8410

View File

@ -2,6 +2,16 @@ import Vue from "vue";
import App from "./App.vue"; import App from "./App.vue";
import router from "./router"; import router from "./router";
import vuetify from './plugins/vuetify'; import vuetify from './plugins/vuetify';
import axios from "axios"
// JWT will be injected automatically when available
axios.interceptors.request.use(config => {
let token = sessionStorage.getItem("jwt")
if (token) {
config.headers.Authorization = token
}
return config
})
Vue.config.productionTip = false; Vue.config.productionTip = false;