diff --git a/packages/nexa-core/core/routes.js b/packages/nexa-core/core/routes.js index 2e34808..4eed7b4 100644 --- a/packages/nexa-core/core/routes.js +++ b/packages/nexa-core/core/routes.js @@ -12,6 +12,9 @@ const routesFolder = path.join(NEXA_MAIN_LOCATION, '../routes'); const convertToRoutePath = (filePath) => { let routePath = filePath.replace(routesFolder, '').replace(/\.js$/, ''); + // Normalize path separators to forward slashes + routePath = routePath.replace(/\\/g, '/'); + // Replace dynamic Next.js routes (e.g., [slug].js) with Express parameters (e.g., :slug) routePath = routePath.replace(/\[(.*?)\]/g, ':$1'); @@ -20,6 +23,9 @@ const convertToRoutePath = (filePath) => { return '/'; // Home route } + if (!routePath.startsWith('/')) routePath = '/' + routePath; + routePath = routePath.replace(/\/+/g, '/'); + return routePath; };