egg-catcher-api / src /api.js
Abhinay
Add VITE_API_BASE + HF Space and Vercel deploy configs
810ed38
Raw
History Blame Contribute Delete
477 Bytes
// Resolve API base URL.
// - Dev: empty string → relative /api/* hits Vite's proxy to localhost:5174
// - All-in-one prod: empty string → relative /api/* hits the same Express server that serves dist/
// - Split prod (frontend on Vercel, backend on HF Space): set VITE_API_BASE=https://<space>.hf.space at build time
const RAW = import.meta.env.VITE_API_BASE || '';
export const API_BASE = RAW.replace(/\/+$/, '');
export function api(path) {
return API_BASE + path;
}