- Fixed API client to respect empty VITE_API_URL for same-origin requests - Fixed video URL construction in videoPlaylist.ts - Fixed video URL construction in VideoUpload.tsx - All three files now use explicit undefined check instead of || operator - Enables proper same-origin requests via nginx proxy in Docker Co-Authored-By: Auggie
27 lines
596 B
TypeScript
27 lines
596 B
TypeScript
import axios from 'axios';
|
|
|
|
const API_URL = import.meta.env.VITE_API_URL !== undefined ? import.meta.env.VITE_API_URL : 'http://localhost:3000';
|
|
|
|
export const api = axios.create({
|
|
baseURL: API_URL,
|
|
withCredentials: true,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
});
|
|
|
|
// Response interceptor for error handling
|
|
api.interceptors.response.use(
|
|
(response) => response,
|
|
(error) => {
|
|
if (error.response?.status === 401) {
|
|
// Redirect to login on unauthorized
|
|
window.location.href = '/login';
|
|
}
|
|
return Promise.reject(error);
|
|
}
|
|
);
|
|
|
|
export default api;
|
|
|