From 95c149f76bd056f77b9890f49799f0fae01af42b Mon Sep 17 00:00:00 2001 From: Nick Galloway Date: Fri, 7 Jul 2017 12:59:29 -0500 Subject: [PATCH] adding ability to send res with middleware --- lib/app/server.js | 1 + lib/app/utils.js | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/app/server.js b/lib/app/server.js index 7bcc1eb43a..0c0b2a5c9d 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -98,6 +98,7 @@ export default async (context) => { if (!context.nuxt.error) { await middlewareSeries(midd, ctx) } + if (context.res.headersSent) return if (context.redirected) return _noopApp // Set layout let layout = Components.length ? Components[0].options.layout : NuxtError.layout diff --git a/lib/app/utils.js b/lib/app/utils.js index 8260b383d4..fa1c3664fa 100644 --- a/lib/app/utils.js +++ b/lib/app/utils.js @@ -104,6 +104,7 @@ export function middlewareSeries (promises, context) { } return promisify(promises[0], context) .then(() => { + if (context.res.headersSent) return return middlewareSeries(promises.slice(1), context) }) }