Route 404 error when missing trailing slash in URL
ewrogers opened this issue · comments
The router will fail to find the route handler when the URL being accessed does not end with a trailing slash (/
).
Example:
const router = new Router({ prefix: '/users' })
router.get('/', ...)
You can access the GET /users/
route just fine, but GET /users
will 404. Just checked koa-router
and it will resolve the route properly.
Seems like a bug.
I cannot reproduce your example. I got 404 for both GET /users/
and GET /users
.
Sorry there was a typo in my example, should have been new Router({ prefix: '/users' })
. Given that you still could not reproduce?
I see. This is because #2 where it just use path = this.opts.prefix + path
to calculate the actual router path. I think I'll try to fix it next week when I'm back from vacation.