eggjs2.x router 解析问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012769002/article/details/81369686
router规则
router.get('/api/users/:id', app.controller.user.show);
router.get('/api/users/login', app.controller.user.login);

在上述规则下请求/api/users/login, 路由会匹配到第一个将’login’字符串当做id

这是eggjs 升级2.x之后出现的问题,在eggjs 1.x版本下不会出现上述问题,可以正确解析。


github上有人提出issue,确实会出现这样的问题,官方建议不要写有歧义的路由,如果业务需要的话将通配的路由写在后面


issue链接

猜你喜欢

转载自blog.csdn.net/u012769002/article/details/81369686