Added API
This commit is contained in:
@@ -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
|
||||
})
|
||||
Reference in New Issue
Block a user