18 lines
381 B
TypeScript
18 lines
381 B
TypeScript
import ky from "ky";
|
|
import useAuthStore from "../stores/useAuthStore";
|
|
|
|
const api = ky.extend({
|
|
prefixUrl: `${import.meta.env.VITE_API_URL}`,
|
|
hooks: {
|
|
beforeRequest: [
|
|
(request) => {
|
|
const accessToken = useAuthStore.getState().accessToken;
|
|
|
|
request.headers.set("Authorization", `Bearer ${accessToken}`);
|
|
},
|
|
],
|
|
},
|
|
});
|
|
|
|
export default api;
|