nidus-sync/ts/client.ts

25 lines
541 B
TypeScript
Raw Normal View History

2026-03-23 14:39:57 -07:00
// src/api/axios.js or similar
import axios from "axios";
import router from "@/router";
2026-03-23 14:39:57 -07:00
const apiClient = axios.create({
baseURL: "/api",
withCredentials: true,
2026-03-23 14:39:57 -07:00
});
// 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);
},
2026-03-23 14:39:57 -07:00
);
apiClient.isAuthenticated = () => {
return true;
};
2026-03-23 14:39:57 -07:00
export default apiClient;