mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
fix(layout-middleware): Fix issue #4724
This commit is contained in:
parent
2bde11f77d
commit
521ac20e29
@ -196,8 +196,9 @@ function callMiddleware(Components, context, layout) {
|
|||||||
// If layout is undefined, only call global middleware
|
// If layout is undefined, only call global middleware
|
||||||
if (typeof layout !== 'undefined') {
|
if (typeof layout !== 'undefined') {
|
||||||
midd = [] // Exclude global middleware if layout defined (already called before)
|
midd = [] // Exclude global middleware if layout defined (already called before)
|
||||||
if (layout.middleware) {
|
const layoutMiddleware = layout.middleware || layout.options.middleware
|
||||||
midd = midd.concat(layout.middleware)
|
if (layoutMiddleware) {
|
||||||
|
midd = midd.concat(layoutMiddleware)
|
||||||
}
|
}
|
||||||
Components.forEach((Component) => {
|
Components.forEach((Component) => {
|
||||||
if (Component.options.middleware) {
|
if (Component.options.middleware) {
|
||||||
|
@ -136,7 +136,8 @@ export default async (ssrContext) => {
|
|||||||
** Call middleware (layout + pages)
|
** Call middleware (layout + pages)
|
||||||
*/
|
*/
|
||||||
midd = []
|
midd = []
|
||||||
if (layout.middleware) midd = midd.concat(layout.middleware)
|
const layoutMiddleware = layout.middleware || layout.options.middleware
|
||||||
|
if (layoutMiddleware) midd = midd.concat(layoutMiddleware)
|
||||||
Components.forEach((Component) => {
|
Components.forEach((Component) => {
|
||||||
if (Component.options.middleware) {
|
if (Component.options.middleware) {
|
||||||
midd = midd.concat(Component.options.middleware)
|
midd = midd.concat(Component.options.middleware)
|
||||||
|
Loading…
Reference in New Issue
Block a user