qualifier / frontend /src /lib /api.js
Sethu0330's picture
Add FTL RFQ Qualifier agent + full SALES CRM app for HF Spaces testing
005df22 unverified
Raw History Blame Contribute Delete
664 Bytes
/** Set when the frontend and API aren't same-origin (e.g. a standalone Azure Function App
* backend) — empty string keeps existing relative-path behavior (HF Spaces, local dev). */
const API_BASE_URL = (import.meta.env.VITE_API_BASE_URL || '').replace(/\/$/, '');
export function apiUrl(path) {
return API_BASE_URL && path.startsWith('/api') ? `${API_BASE_URL}${path}` : path;
}
/** Browser cookie session + tenant APIs require credentials on same-origin / proxied /api calls. */
export function apiFetch(input, init = {}) {
const url = typeof input === 'string' ? apiUrl(input) : input;
return fetch(url, { credentials: 'include', ...init });
}