From c24e13c29ae929ffad2df1085c664e0e06f1b473 Mon Sep 17 00:00:00 2001 From: Zino Platform Date: Thu, 13 Aug 2026 11:03:30 +0000 Subject: [PATCH] resolve SAME_ORIGIN runtime config so custom domains call their own origin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/api/config.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/api/config.ts b/src/api/config.ts index c5b543c..d373aa3 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 = {