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) }) }