From 694fddcbad785578c0a0dbf601d203b3389d29eb Mon Sep 17 00:00:00 2001 From: Timofei Iatsenko Date: Tue, 26 Nov 2024 12:46:03 +0100 Subject: [PATCH] fix(preview): fix router when deployed on subpath --- apps/preview/app/src/routes.tsx | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/apps/preview/app/src/routes.tsx b/apps/preview/app/src/routes.tsx index 8a1afa85..7014f7a1 100644 --- a/apps/preview/app/src/routes.tsx +++ b/apps/preview/app/src/routes.tsx @@ -40,18 +40,23 @@ const getRoutes = (templates: TemplateData[]) => { export const getRouter = (templates: Record) => { const { routes, templateParts } = getRoutes(Object.values(templates)); - const router = createBrowserRouter([ + const router = createBrowserRouter( + [ + { + element: ( + + + + ), + errorElement: , + path: '/' + }, + ...routes + ], { - element: ( - - - - ), - errorElement: , - path: import.meta.env.VITE_JSXEMAIL_BASE_PATH || '/' - }, - ...routes - ]); + basename: import.meta.env.VITE_JSXEMAIL_BASE_PATH + } + ); return router; };