We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents b7f285f + f478d18 commit c588423Copy full SHA for c588423
template/server/index.js
@@ -19,17 +19,11 @@ async function start () {
19
await builder.build()
20
}
21
22
- app.use(async (ctx, next) => {
23
- await next()
24
- ctx.status = 200 // koa defaults to 404 when it sees that status is unset
25
- return new Promise((resolve, reject) => {
26
- ctx.res.on('close', resolve)
27
- ctx.res.on('finish', resolve)
28
- nuxt.render(ctx.req, ctx.res, promise => {
29
- // nuxt.render passes a rejected promise into callback on error.
30
- promise.then(resolve).catch(reject)
31
- })
32
+ app.use(ctx => {
+ ctx.status = 200
+ ctx.respond = false // Mark request as handled for Koa
+ ctx.req.ctx = ctx // This might be useful later on, e.g. in nuxtServerInit or with nuxt-stash
+ nuxt.render(ctx.req, ctx.res)
33
})
34
35
app.listen(port, host)
0 commit comments