Added API

This commit is contained in:
2026-06-21 16:53:39 +10:00
parent 5850c849d0
commit 07e2796e09
12 changed files with 124 additions and 36 deletions
+17
View File
@@ -0,0 +1,17 @@
import axios from 'axios'
import { usePage } from '@inertiajs/vue3'
import {SharedProps} from "@/Types/types";
export const api = axios.create({
baseURL: import.meta.env.VITE_API_URL,
withCredentials: true,
headers: { Accept: 'application/json' },
})
api.interceptors.request.use((config) => {
const token = usePage<SharedProps>().props.auth?.apiToken
if (token) {
config.headers.Authorization = `Bearer ${token}`
}
return config
})