This is my koa app that serves nuxt app.
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Can't set headers after they are sent.
import Koa from 'koa'
import { Nuxt, Builder } from 'nuxt'
import config from './../nuxt.config.js'
const app = new Koa()
config.dev = !(process.env.NODE_ENV === 'production')
const nuxt = new Nuxt(config)
if (config.dev) {
const builder = new Builder(nuxt)
builder.build()
}
app.use(async (ctx, next) => {
ctx.status = 200
await nuxt.render(ctx.req, ctx.res)
})
app.listen(3000)
console.log('Server listening')
Note that following piece of code is exactly the same I used with nuxt 1.0.0-alpha.4
app.use(async (ctx, next) => {
ctx.status = 200
await nuxt.render(ctx.req, ctx.res)
})
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1063">#c1063</a>)</em></sub></div>