Files
klapi/ui/src/api/url.ts

8 lines
263 B
TypeScript

const API_BASE_URL =
(typeof process !== "undefined" ? process.env?.API_BASE_URL : undefined) ??
import.meta.env.VITE_API_BASE_URL ??
"/api";
export const buildApiUrl = (path: string) =>
`${API_BASE_URL.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;