fix: Handle middleware fn in nuxt.config.js

This commit is contained in:
Atinux 2017-11-03 17:24:20 +01:00
parent 23919a9e01
commit e97bb1d099
2 changed files with 2 additions and 2 deletions

View File

@ -101,7 +101,7 @@ export default async ssrContext => {
/*
** Call global middleware (nuxt.config.js)
*/
let midd = <%= serialize(router.middleware, { isJSON: true }) %>
let midd = <%= serialize(router.middleware).replace('middleware(', 'function(') %>
midd = midd.map((name) => {
if (typeof name === 'function') return name
if (typeof middleware[name] !== 'function') {

View File

@ -19,7 +19,7 @@ Options.from = function (_options) {
if (options.loading === true) {
delete options.loading
}
if (options.router && typeof options.router.middleware === 'string') {
if (options.router && options.router.middleware && !Array.isArray(options.router.middleware)) {
options.router.middleware = [options.router.middleware]
}
if (options.router && typeof options.router.base === 'string') {