diff --git a/src/index.tsx b/src/index.tsx index 68af126..8ddfddb 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -5,6 +5,7 @@ import "./index.css"; import configureStore from "./redux/configureStore"; import { Provider as ReduxProvider } from "react-redux"; import "./utils/i18n"; +import { getRouterBasePath } from "./utils/paths"; const store = configureStore(); @@ -17,7 +18,7 @@ const root = createRoot(container); root.render( - + diff --git a/src/utils/paths.ts b/src/utils/paths.ts index c95cb62..20b606c 100644 --- a/src/utils/paths.ts +++ b/src/utils/paths.ts @@ -14,3 +14,12 @@ export const getPublicPath = (path: string): string => { const normalizedBase = basePath.endsWith("/") ? basePath : `${basePath}/`; return `${normalizedBase}${cleanPath}`; }; + +export const getRouterBasePath = (): string | undefined => { + const basePath = getBasePath(); + if (basePath === "/") return undefined; + // Remove trailing slash if present and ensure it starts with a slash + let baseUrl = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath; + baseUrl = baseUrl.startsWith("/") ? baseUrl : `/${baseUrl}`; + return baseUrl; +};