diff --git a/src/api/config.ts b/src/api/config.ts index 63789f1..6631311 100644 --- a/src/api/config.ts +++ b/src/api/config.ts @@ -13,9 +13,16 @@ export const APP_ID = '434'; declare global { interface Window { __RUNTIME_CONFIG__?: Record } } +const runtimeApiURL = + typeof window !== 'undefined' ? window.__RUNTIME_CONFIG__?.VITE_ZINO_API_URL : undefined; + +// SAME_ORIGIN means "call the host that served this page": on a custom domain the +// same Ingress serves /usr and /app/, so the API is this origin. It is a sentinel +// rather than '' because the || below treats '' as absent and falls through. export const BASE_URL = - (typeof window !== 'undefined' && window.__RUNTIME_CONFIG__?.VITE_ZINO_API_URL) || - 'https://dev.getzino.in'; + runtimeApiURL === 'SAME_ORIGIN' + ? window.location.origin.replace(/\/$/, '') + : runtimeApiURL || 'https://dev.getzino.in'; // --- Order Booking (src/docs/api/order_booking.md) --- export const ORDER_BOOKING = {