Spaces:
Runtime error
Runtime error
Download frontend/src/config/apiBase.js from cuiconnect/backend: direct link, hf CLI and curl.
- Browser
- Download file 831 Bytes
-
https://huggingface.co/spaces/cuiconnect/backend/resolve/main/frontend/src/config/apiBase.js
- Command line
-
hf download hf://spaces/cuiconnect/backend/frontend/src/config/apiBase.js
-
curl -L -o apiBase.js https://huggingface.co/spaces/cuiconnect/backend/resolve/main/frontend/src/config/apiBase.js
831 Bytes
| function stripTrailingSlash(url) { | |
| return url.replace(/\/+$/, '') | |
| } | |
| /** | |
| * Backend URL for production (e.g. Hugging Face Space). Override with `VITE_API_BASE` | |
| * in Vercel Project → Environment Variables if needed. | |
| * In development, empty base keeps `/users`, `/response`, … as relative URLs → Vite proxy. | |
| */ | |
| export function getApiBase() { | |
| const fromEnv = import.meta.env.VITE_API_BASE | |
| if (fromEnv != null && String(fromEnv).trim() !== '') { | |
| return stripTrailingSlash(String(fromEnv).trim()) | |
| } | |
| if (import.meta.env.PROD) { | |
| return 'https://cuiconnect-backend.hf.space' | |
| } | |
| return '' | |
| } | |
| /** | |
| * @param {string} path - absolute path (e.g. `/users/login`) | |
| */ | |
| export function apiUrl(path) { | |
| const base = getApiBase() | |
| const p = path.startsWith('/') ? path : `/${path}` | |
| return base ? `${base}${p}` : p | |
| } | |