hotfix(layout): Hot fix for layout middleware

This commit is contained in:
Sébastien Chopin 2019-01-10 19:57:32 +01:00
parent 521ac20e29
commit 3ebd6b707e
3 changed files with 6 additions and 6 deletions

View File

@ -196,9 +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)
const layoutMiddleware = layout.middleware || layout.options.middleware
if (layoutMiddleware) {
midd = midd.concat(layoutMiddleware)
layout = sanitizeComponent(layout)
if (layout.options.middleware) {
midd = midd.concat(layout.options.middleware)
}
Components.forEach((Component) => {
if (Component.options.middleware) {

View File

@ -1,7 +1,7 @@
import { stringify } from 'querystring'
import Vue from 'vue'
import middleware from './middleware.js'
import { applyAsyncData, getMatchedComponents, middlewareSeries, promisify, urlJoin } from './utils.js'
import { applyAsyncData, getMatchedComponents, middlewareSeries, promisify, urlJoin, sanitizeComponent } from './utils.js'
import { createApp, NuxtError } from './index.js'
import NuxtLink from './components/nuxt-link.server.js' // should be included after ./index.js
@ -136,8 +136,8 @@ export default async (ssrContext) => {
** Call middleware (layout + pages)
*/
midd = []
const layoutMiddleware = layout.middleware || layout.options.middleware
if (layoutMiddleware) midd = midd.concat(layoutMiddleware)
layout = sanitizeComponent(layout)
if (layout.options.middleware) midd = midd.concat(layout.options.middleware)
Components.forEach((Component) => {
if (Component.options.middleware) {
midd = midd.concat(Component.options.middleware)