diff --git a/packages/kit/src/pages.ts b/packages/kit/src/pages.ts index 3e36eb2c03..a5f7fc1d3e 100644 --- a/packages/kit/src/pages.ts +++ b/packages/kit/src/pages.ts @@ -53,12 +53,12 @@ export function addRouteMiddleware (input: NuxtMiddleware | NuxtMiddleware[], op if (find >= 0) { if (app.middleware[find].path === middleware.path) { continue } if (options.override === true) { - app.middleware[find] = middleware + app.middleware[find] = { ...middleware } } else { logger.warn(`'${middleware.name}' middleware already exists at '${app.middleware[find].path}'. You can set \`override: true\` to replace it.`) } } else { - app.middleware.push(middleware) + app.middleware.push({ ...middleware }) } } })