From 521ac20e298b6a7f090cdedce63098f2c234417f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Thu, 10 Jan 2019 18:59:56 +0100 Subject: [PATCH] fix(layout-middleware): Fix issue #4724 --- packages/vue-app/template/client.js | 5 +++-- packages/vue-app/template/server.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/vue-app/template/client.js b/packages/vue-app/template/client.js index 1794ac53e3..56586077a3 100644 --- a/packages/vue-app/template/client.js +++ b/packages/vue-app/template/client.js @@ -196,8 +196,9 @@ function callMiddleware(Components, context, layout) { // If layout is undefined, only call global middleware if (typeof layout !== 'undefined') { midd = [] // Exclude global middleware if layout defined (already called before) - if (layout.middleware) { - midd = midd.concat(layout.middleware) + const layoutMiddleware = layout.middleware || layout.options.middleware + if (layoutMiddleware) { + midd = midd.concat(layoutMiddleware) } Components.forEach((Component) => { if (Component.options.middleware) { diff --git a/packages/vue-app/template/server.js b/packages/vue-app/template/server.js index 04945c8ba5..cb9531e908 100644 --- a/packages/vue-app/template/server.js +++ b/packages/vue-app/template/server.js @@ -136,7 +136,8 @@ export default async (ssrContext) => { ** Call middleware (layout + pages) */ 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) => { if (Component.options.middleware) { midd = midd.concat(Component.options.middleware)