koa-router 如何处理url没有的情况,默认redirect
发布于 9 年前 作者 petitspois 16027 次浏览 最后一次编辑是 8 年前 来自 问答

ACB64B28-C15A-4DCC-86F9-1CA270FB3C81.png 新手见谅404页面处理

1 回复

自己做middleware吧, 比如:

app.use(function *notFound(next) {
  if (this.status == 404) {
    console.log(this.url, 'requested but no route matches.');
  } else {
    yield next;
  }
});
回到顶部