diff --git a/index.html b/index.html index 5c980c0..2cd6cbd 100644 --- a/index.html +++ b/index.html @@ -10,6 +10,8 @@ Krishna Sales + +
diff --git a/src/App.tsx b/src/App.tsx index 784bc84..0a254c0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -12,10 +12,16 @@ function RootRedirect() { return ; } +// Mount path comes from the document the frontgen server writes at +// placement time (e.g. "/krishna-sales-mobile/"), so one built artifact serves +// any mount without a hardcoded slug. Falls back to "/" for local dev. +const routerBasename = + (document.querySelector('base')?.getAttribute('href') || '/').replace(/\/$/, '') || '/' + function App() { return ( - + } /> }> diff --git a/src/api/config.ts b/src/api/config.ts index f6c2d45..63789f1 100644 --- a/src/api/config.ts +++ b/src/api/config.ts @@ -5,7 +5,17 @@ // docs under src/docs/api. export const APP_ID = '434'; -export const BASE_URL = 'https://dev.getzino.in'; + +// Backend URL comes from the runtime config.js the frontgen server writes at +// placement time (window.__RUNTIME_CONFIG__.VITE_ZINO_API_URL) so one built +// artifact can be promoted across environments. The dev literal is only a +// fallback for local dev / a build served without config.js. +declare global { + interface Window { __RUNTIME_CONFIG__?: Record } +} +export const BASE_URL = + (typeof window !== 'undefined' && window.__RUNTIME_CONFIG__?.VITE_ZINO_API_URL) || + 'https://dev.getzino.in'; // --- Order Booking (src/docs/api/order_booking.md) --- export const ORDER_BOOKING = { diff --git a/vite.config.ts b/vite.config.ts index 214f897..3ea547c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,7 +4,11 @@ import tailwindcss from '@tailwindcss/vite' import { VitePWA } from 'vite-plugin-pwa' // https://vite.dev/config/ -const base = process.env.VITE_BASE_URL ?? '/krishna_sales_mobile' +// Relative base so the built artifact is mount-path agnostic; the frontgen +// server writes the real into index.html at placement time. +// PWA manifest start_url/scope + workbox fallback concatenate this, so they +// stay relative too and resolve under whatever mount serves the app. +const base = './' export default defineConfig({ base,