fix(kit): don't warn if middleware is added twice

This commit is contained in:
Daniel Roe 2024-02-26 19:21:25 +00:00
parent 196223c0fb
commit 08b656a047

View File

@ -51,6 +51,7 @@ export function addRouteMiddleware (input: NuxtMiddleware | NuxtMiddleware[], op
for (const middleware of middlewares) { for (const middleware of middlewares) {
const find = app.middleware.findIndex(item => item.name === middleware.name) const find = app.middleware.findIndex(item => item.name === middleware.name)
if (find >= 0) { if (find >= 0) {
if (app.middleware[find].path === middleware.path) { continue }
if (options.override === true) { if (options.override === true) {
app.middleware[find] = middleware app.middleware[find] = middleware
} else { } else {