const Koa = require('koa')
const next = require('next')
const Router = require('koa-router')

const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()

app.prepare()
.then(() => {
  const server = new Koa()
  const router = new Router()

  router.get('/a', function *() {
    app.render(this.req, this.res, '/b', this.query)
    this.respond = false
  })

  router.get('/b', function *() {
    app.render(this.req, this.res, '/a', this.query)
    this.respond = false
  })

  router.get('*', function *() {
    handle(this.req, this.res)
    this.respond = false
  })

  server.use(router.routes())
  server.listen(3000, (err) => {
    if (err) throw err
    console.log('> Ready on http://localhost:3000')
  })
})

@@ -620,16 +620,192 @@
 e%0A  %7D)%0A%0A
+  server.use(function *(next) %7B%0A    // Koa doesn't seems to set the default statusCode.%0A    // So, this middleware does that%0A    this.res.statusCode = 200%0A    yield next%0A  %7D)%0A%0A
   server

Fix koa-404 issue by adding res.statusCode to 200 (#815)