resolve SAME_ORIGIN runtime config so custom domains call their own origin

frontgen writes VITE_ZINO_API_URL=SAME_ORIGIN for custom-domain placements.
The old expression passed that string straight through as BASE_URL, so every
API call went to /SAME_ORIGIN/app/434/... which the SPA fallback answers with
index.html — the page rendered and no data loaded.

Absolute platform URL is still used for the preview mount and local dev.
This commit is contained in:
Zino Platform 2026-08-13 11:03:30 +00:00
parent 3f12e80f38
commit c24e13c29a

View File

@ -13,9 +13,16 @@ export const APP_ID = '434';
declare global {
interface Window { __RUNTIME_CONFIG__?: Record<string, string> }
}
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 = {