Skip to content

Commit

Permalink
fix(preview): fix router when deployed on subpath
Browse files Browse the repository at this point in the history
  • Loading branch information
timofei-iatsenko committed Nov 26, 2024
1 parent 534a1be commit 694fddc
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions apps/preview/app/src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,23 @@ const getRoutes = (templates: TemplateData[]) => {

export const getRouter = (templates: Record<string, TemplateData>) => {
const { routes, templateParts } = getRoutes(Object.values(templates));
const router = createBrowserRouter([
const router = createBrowserRouter(
[
{
element: (
<Layout>
<Home templateParts={templateParts} />
</Layout>
),
errorElement: <Error />,
path: '/'
},
...routes
],
{
element: (
<Layout>
<Home templateParts={templateParts} />
</Layout>
),
errorElement: <Error />,
path: import.meta.env.VITE_JSXEMAIL_BASE_PATH || '/'
},
...routes
]);
basename: import.meta.env.VITE_JSXEMAIL_BASE_PATH
}
);

return router;
};

0 comments on commit 694fddc

Please sign in to comment.