From e97bb1d099df31f620e34ed4c52bc0f7aeeba33c Mon Sep 17 00:00:00 2001 From: Atinux Date: Fri, 3 Nov 2017 17:24:20 +0100 Subject: [PATCH] fix: Handle middleware fn in nuxt.config.js --- lib/app/server.js | 2 +- lib/common/options.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/app/server.js b/lib/app/server.js index fdf484b1da..ac6f004409 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -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') { diff --git a/lib/common/options.js b/lib/common/options.js index b08784aa34..672a216c85 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -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') {