2022-12-20 11:00:36 +00:00
|
|
|
import { boot } from 'quasar/wrappers';
|
|
|
|
import axios from 'axios';
|
2022-12-20 11:30:25 +00:00
|
|
|
import { useSession } from 'src/composables/useSession';
|
2022-12-20 11:00:36 +00:00
|
|
|
|
2022-12-20 11:30:25 +00:00
|
|
|
export default boot(() => {
|
|
|
|
const { getToken } = useSession();
|
2022-12-20 11:00:36 +00:00
|
|
|
|
2022-12-20 11:30:25 +00:00
|
|
|
axios.defaults.baseURL = '/api/';
|
2022-12-20 11:00:36 +00:00
|
|
|
|
2022-12-20 11:30:25 +00:00
|
|
|
axios.interceptors.request.use(
|
|
|
|
function (context) {
|
|
|
|
const token = getToken();
|
2022-12-20 11:00:36 +00:00
|
|
|
|
2022-12-20 11:30:25 +00:00
|
|
|
if (token.length && context.headers) {
|
|
|
|
context.headers.Authorization = token;
|
|
|
|
}
|
2022-12-20 11:00:36 +00:00
|
|
|
|
2022-12-20 11:30:25 +00:00
|
|
|
return context;
|
|
|
|
},
|
|
|
|
function (error) {
|
|
|
|
return Promise.reject(error);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|