diff --git a/lib/app/server.js b/lib/app/server.js index 0c0b2a5c9d..53f2922461 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -98,7 +98,7 @@ export default async (context) => { if (!context.nuxt.error) { await middlewareSeries(midd, ctx) } - if (context.res.headersSent) return + if (context.res && 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 fa1c3664fa..99e45afc8f 100644 --- a/lib/app/utils.js +++ b/lib/app/utils.js @@ -104,7 +104,7 @@ export function middlewareSeries (promises, context) { } return promisify(promises[0], context) .then(() => { - if (context.res.headersSent) return + if (context.res && context.res.headersSent) return return middlewareSeries(promises.slice(1), context) }) }