【发布时间】:2017-12-23 07:42:32
【问题描述】:
我无法在 Express 4.16.2 上将路由参数与 app.use 一起使用。
我有这样的声明:
app.use('/course-sessions/:courseSessionId/chapter-sessions', chapterSessionsRouter)
并且,在章节会话路由器中:
// Index.
router.get('/', ...resource.indexMethods)
当我得到'/course-sessions/0/chapter-sessions/' 时,我得到了 404。
然后我尝试这样的声明:
app.get('/course-sessions/:courseSessionId/chapter-sessions', ...chapterSessionResource.indexMethods)
现在我得到了我想要的结果。所以路由参数不适用于app.use。
在我进行研究时,我收到了 this GitHub issue 和 this pull request 来解决问题。但似乎问题仍然存在。还是我做错了什么?
【问题讨论】:
标签: express routeparams