nidus-sync/ts/client.ts
Eli Ribble 4bbfbdb9e6
Pretty all the things I missed
My laptop didn't have lefthook running. Oops.
2026-03-27 14:06:50 -07:00

24 lines
541 B
TypeScript

// src/api/axios.js or similar
import axios from "axios";
import router from "@/router";
const apiClient = axios.create({
baseURL: "/api",
withCredentials: true,
});
// Response interceptor to catch auth failures
apiClient.interceptors.response.use(
(response) => response,
(error) => {
if (error.response && error.response.status === 401) {
// Session expired or not authenticated
router.push("/login");
}
return Promise.reject(error);
},
);
apiClient.isAuthenticated = () => {
return true;
};
export default apiClient;