Files
FitOS/app/src/config.ts

31 lines
1.1 KiB
TypeScript

/// <reference types="vite/client" />
declare global {
interface Window {
__FITOS_CONFIG__?: { apiUrl?: string; adminUrl?: string };
}
}
// Runtime config (config.js) takes precedence, then build-time VITE_API_URL, then same origin.
export const API_URL: string =
window.__FITOS_CONFIG__?.apiUrl ||
(import.meta.env.VITE_API_URL as string | undefined) ||
window.location.origin;
export const API_BASE = `${API_URL}/api/v1`;
/**
* Origin panelu admina (link „Panel admina" dla administratorów).
* config.js: `adminUrl` (pełny adres) ma pierwszeństwo. Fallback: ten sam host,
* port admina wg znanego mapowania stosów (dev 9001→9000, vite 5173→5174,
* staging 13001→13000). Własne mapowanie portów (prod) = wpis w config.js.
*/
export const ADMIN_URL: string =
window.__FITOS_CONFIG__?.adminUrl ||
(() => {
const { protocol, hostname, port } = window.location;
const adminPort =
port === '9001' ? '9000' : port === '5173' ? '5174' : port === '13001' ? '13000' : port;
return `${protocol}//${hostname}${adminPort ? `:${adminPort}` : ''}`;
})();