build: make artifact placement-portable for frontend releases
- vite base './' (relative refs; PWA manifest/scope/fallback follow via concat) - index.html carries <!--BASE_HREF--> placeholder + ./config.js ref - BASE_URL reads window.__RUNTIME_CONFIG__.VITE_ZINO_API_URL (placement-written) - router basename derived from <base href>, not hardcoded slug Slug renamed krishna_sales_mobile -> krishna-sales-mobile (frontgen slug pattern forbids underscores). Same treatment as the desktop app.
This commit is contained in:
parent
7a3a93d1de
commit
e78aa98677
@ -10,6 +10,8 @@
|
||||
<meta name="apple-mobile-web-app-title" content="Krishna Sales" />
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon-180x180.png" />
|
||||
<title>Krishna Sales</title>
|
||||
<!--BASE_HREF-->
|
||||
<script src="./config.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@ -12,10 +12,16 @@ function RootRedirect() {
|
||||
return <Navigate to={getDefaultRoute(roles, isAdmin)} replace />;
|
||||
}
|
||||
|
||||
// Mount path comes from the document <base href> 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 (
|
||||
<AuthProvider>
|
||||
<BrowserRouter basename='/krishna_sales_mobile'>
|
||||
<BrowserRouter basename={routerBasename}>
|
||||
<Routes>
|
||||
<Route path="/login" element={<LoginPage />} />
|
||||
<Route element={<ConsoleLayout />}>
|
||||
|
||||
@ -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<string, string> }
|
||||
}
|
||||
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 = {
|
||||
|
||||
@ -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 <base href> 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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user