testtest123's picture
feat: enterprise multi-page RAG platform with GraphRAG, CRAG, Guardrails, and VectorDB Inspector
73905db
Raw
History Blame Contribute Delete
620 Bytes
import axios from 'axios';
const getApiBaseUrl = () => {
if (import.meta.env.VITE_API_BASE_URL) return import.meta.env.VITE_API_BASE_URL;
if (typeof window !== 'undefined' && (window.location.port === '5173' || window.location.port === '5174')) {
return 'http://127.0.0.1:8008';
}
return window.location.origin;
};
const api = axios.create({
baseURL: getApiBaseUrl(),
});
// Interceptor for JWT
api.interceptors.request.use((config) => {
const token = sessionStorage.getItem('token');
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
return config;
});
export default api;