From 149c8998babe318387722f9b7d26240c1c8615e1 Mon Sep 17 00:00:00 2001 From: wesleybl Date: Fri, 15 Mar 2024 10:53:40 -0300 Subject: [PATCH] Add routes with prefix path This is necessary for component properties to work correctly in SSR, when we use prefix --- packages/volto/src/routes.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/volto/src/routes.js b/packages/volto/src/routes.js index a1fb227a57..9e04390c8b 100644 --- a/packages/volto/src/routes.js +++ b/packages/volto/src/routes.js @@ -124,7 +124,7 @@ export function getExternalRoutes() { ); } -export const defaultRoutes = [ +const baseRoutes = [ // redirect to external links if path is in blacklist ...getExternalRoutes(), ...((config.settings?.isMultilingual && multilingualRoutes) || []), @@ -313,6 +313,9 @@ export const defaultRoutes = [ component: PersonalInformation, exact: true, }, +]; + +const fallbackRoutes = [ { path: '/**', component: View, @@ -323,6 +326,20 @@ export const defaultRoutes = [ }, ]; +let prefixRoutes = []; +if (config.settings.prefixPath) { + prefixRoutes = baseRoutes.map((route) => ({ + ...route, + path: `${config.settings.prefixPath}${route['path']}`, + })); +} + +export const defaultRoutes = [ + ...baseRoutes, + ...prefixRoutes, + ...fallbackRoutes, +]; + /** * Routes array. * @array