19 lines
561 B
TypeScript
19 lines
561 B
TypeScript
import axios, {type AxiosInstance} from "axios";
|
|
import {Session} from "~/auth/Session";
|
|
|
|
export const MavenApi: AxiosInstance = function()
|
|
{
|
|
const instance: AxiosInstance = axios.create({
|
|
baseURL: 'http://localhost:8080'
|
|
});
|
|
instance.interceptors.request.use((config) =>
|
|
{
|
|
const session: Session = useCookie<Session>(Session.COOKIE).value
|
|
if (session)
|
|
{
|
|
config.headers["Authorization"] = StringUtils.format("Bearer %s", session.token)
|
|
}
|
|
return config;
|
|
})
|
|
return instance;
|
|
}(); |