From 1ab4be456f1262d1ebace9c1b6a332c63a851aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Fri, 26 Jan 2018 12:16:53 +0100 Subject: [PATCH] fix: Handle redirect in middleware, fix #542 and #2665 --- lib/app/client.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/app/client.js b/lib/app/client.js index 183ee91d04..dc376da6da 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -226,11 +226,11 @@ async function render (to, from, next) { if (!Components.length) { // Default layout await callMiddleware.call(this, Components, app.context) - if (app.context._redirected) return + if (nextCalled) return // Load layout for error page const layout = await this.loadLayout(typeof NuxtError.layout === 'function' ? NuxtError.layout(app.context) : NuxtError.layout) await callMiddleware.call(this, Components, app.context, layout) - if (app.context._redirected) return + if (nextCalled) return // Show error page app.context.error({ statusCode: 404, message: '<%= messages.error_404 %>' }) return next() @@ -250,7 +250,7 @@ async function render (to, from, next) { try { // Call middleware await callMiddleware.call(this, Components, app.context) - if (app.context._redirected) return + if (nextCalled) return if (app.context._errored) return next() // Set layout @@ -262,7 +262,7 @@ async function render (to, from, next) { // Call middleware for layout await callMiddleware.call(this, Components, app.context, layout) - if (app.context._redirected) return + if (nextCalled) return if (app.context._errored) return next() // Call .validate()