【发布时间】:2018-10-29 15:35:45
【问题描述】:
来自https://github.com/koajs/jwt
app.use(jwt({ secret: 'shared-secret' }));
用于保护跟随的路线。
问题:如何只为定义的路由集指定它,并在没有匹配路径时重定向到静态 html 页面。
我当前的代码:
app
.use(indexRouter.routes())
.use(jwt({secret: conf.secret }))
.use(protectedRouter.routes())
.use((ctx: any)=> ctx.body='My html page'); <-- this doesn't work because it is considered a protected route
预期的伪代码:
app.use(indexRouter.routes())
.use(protectedRouter.routes(), jwt({secret: conf.secret }))
.use((ctx: any)=> ctx.body='My html page');
【问题讨论】: