A deployable markdown editor that connects with your self hosted files and lets you edit in a beautiful interface
at main 25 lines 678 B view raw
1import axios from 'axios'; 2 3const API_BASE_URL = import.meta.env.PUBLIC_API_URL || 'http://localhost:8080'; 4 5export const apiClient = axios.create({ 6 baseURL: API_BASE_URL, 7 withCredentials: true, // Important for session cookies 8 headers: { 9 'Content-Type': 'application/json', 10 }, 11}); 12 13// Response interceptor for error handling 14apiClient.interceptors.response.use( 15 (response) => response, 16 (error) => { 17 if (error.response?.status === 401) { 18 // Redirect to login on unauthorized 19 if (typeof window !== 'undefined' && !window.location.pathname.includes('/')) { 20 window.location.href = '/'; 21 } 22 } 23 return Promise.reject(error); 24 } 25);