mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-13 09:33:54 +00:00
fix(kit): clone middleware when adding to app
This commit is contained in:
parent
4be430e13f
commit
5be9253cfe
@ -53,12 +53,12 @@ export function addRouteMiddleware (input: NuxtMiddleware | NuxtMiddleware[], op
|
|||||||
if (find >= 0) {
|
if (find >= 0) {
|
||||||
if (app.middleware[find].path === middleware.path) { continue }
|
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 {
|
||||||
logger.warn(`'${middleware.name}' middleware already exists at '${app.middleware[find].path}'. You can set \`override: true\` to replace it.`)
|
logger.warn(`'${middleware.name}' middleware already exists at '${app.middleware[find].path}'. You can set \`override: true\` to replace it.`)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
app.middleware.push(middleware)
|
app.middleware.push({ ...middleware })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user