Spaces:
Running
Running
Download frontend/src/utils/apiBase.ts from Falln87/OmniVoice-Studio: direct link, hf CLI and curl.
- Browser
- Download file 912 Bytes
-
https://huggingface.co/spaces/Falln87/OmniVoice-Studio/resolve/main/frontend/src/utils/apiBase.ts
- Command line
-
hf download hf://spaces/Falln87/OmniVoice-Studio/frontend/src/utils/apiBase.ts
-
curl -L -o apiBase.ts https://huggingface.co/spaces/Falln87/OmniVoice-Studio/resolve/main/frontend/src/utils/apiBase.ts
912 Bytes
| /** | |
| * Centralised API base URL resolver — Docker/HF Spaces deployment. | |
| * | |
| * In Docker, frontend and backend share the same origin (port 3900), | |
| * so we simply use window.location.origin for everything. | |
| */ | |
| declare global { | |
| interface Window { | |
| __TAURI_INTERNALS__?: unknown; | |
| __TAURI__?: unknown; | |
| } | |
| } | |
| export const BACKEND_PORT = 3900; | |
| export function isTauriContext(): boolean { | |
| return ( | |
| typeof window !== "undefined" && | |
| !!(window.__TAURI_INTERNALS__ || window.__TAURI__) | |
| ); | |
| } | |
| export function getApiBase(): string { | |
| // Docker/HF Spaces: same-origin serving | |
| if (typeof window !== "undefined" && window.location) { | |
| return window.location.origin; | |
| } | |
| return `http://localhost:${BACKEND_PORT}`; | |
| } | |
| function stripTrailingSlash(url: string): string { | |
| return url.endsWith("/") ? url.slice(0, -1) : url; | |
| } | |
| export const API_BASE: string = getApiBase(); | |
| export default API_BASE; | |