programatic usage with koa fails since migration from 1.0.0-alpha.4 to v1.0.0-rc3
[issue link]This is my koa app that serves nuxt app.
- if NODE_ENV=production it always serves “OK” and nothing happens on server
- if NODE_ENV=development it always serves “OK” and in server logs I see that app fetches async data and then there is error
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Can't set headers after they are sent. - it works with express
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)
})