Files
FlightsAPI/resources/js/api.ts
T
2026-06-21 16:53:39 +10:00

18 lines
471 B
TypeScript

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
})