diff --git a/src/rollup/plugins/handlers.ts b/src/rollup/plugins/handlers.ts index 833fb8f61b..3e50b2fccc 100644 --- a/src/rollup/plugins/handlers.ts +++ b/src/rollup/plugins/handlers.ts @@ -48,7 +48,7 @@ ${imports.map(handler => `import ${getImportId(handler)} from '${handler}';`).jo ${lazyImports.map(handler => `const ${getImportId(handler)} = () => import('${handler}');`).join('\n')} export const handlers = [ -${handlers.map(h => ` { route: '${h.route || ''}', handler: ${getImportId(h.handler)}, lazy: ${h.lazy || true}, middleware: ${!!h.middleware}, method: ${JSON.stringify(h.method)} }`).join(',\n')} +${handlers.map(h => ` { route: '${h.route || ''}', handler: ${getImportId(h.handler)}, lazy: ${!!h.lazy}, middleware: ${!!h.middleware}, method: ${JSON.stringify(h.method)} }`).join(',\n')} ]; `.trim() return code diff --git a/src/scan.ts b/src/scan.ts index 94d6b3bc86..43e05bd4ee 100644 --- a/src/scan.ts +++ b/src/scan.ts @@ -48,6 +48,7 @@ export function scanRoutes (nitro: Nitro, dir: string, prefix: string = '/') { return { handler: file.fullPath, + lazy: true, route, method }