upd
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import ky from "ky";
|
||||
import useAuthStore from "../stores/useAuthStore";
|
||||
|
||||
const api = ky.create({
|
||||
prefixUrl: import.meta.env.VITE_API_URL,
|
||||
retry: 0,
|
||||
hooks: {
|
||||
beforeRequest: [
|
||||
(request) => {
|
||||
const token = useAuthStore.getState().token;
|
||||
|
||||
if (token) {
|
||||
request.headers.set("Authorization", `Bearer ${token}`);
|
||||
}
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
export default api;
|
||||
Reference in New Issue
Block a user