fix(router): derive basename from <base href>, not hardcoded /krishna_sales

The mount path is set per-placement by the frontgen server's <base href>
(/krishna-sales/ on qa). The hardcoded /krishna_sales basename didn't match,
so the Router refused to render. Read it from the document base so one
artifact serves any mount path.
This commit is contained in:
ashwinkumaragurubaran 2026-08-05 15:50:02 +05:30
parent 72ddba1c06
commit d6bcee2ed5

View File

@ -14,10 +14,16 @@ function RootRedirect() {
import { routeConfig } from './routesConfig' import { routeConfig } from './routesConfig'
// Mount path comes from the document <base href> the frontgen server writes at
// placement time (e.g. "/krishna-sales/"), 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() { function App() {
return ( return (
<AuthProvider> <AuthProvider>
<BrowserRouter basename="/krishna_sales"> <BrowserRouter basename={routerBasename}>
<Routes> <Routes>
<Route path="/login" element={<LoginPage />} /> <Route path="/login" element={<LoginPage />} />
<Route element={<ConsoleLayout />}> <Route element={<ConsoleLayout />}>