We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I tried to explore the nested routers by adding the router prefix in it, but it responds with the status code 404.
Here is working example without adding the router prefix:
var forums = new Router(); var posts = new Router(); posts.get('/', function *(next) {...}); posts.get('/:pid', function *(next) {...}); forums.use('/forums/:fid/posts', posts.routes()); app.use(forums.routes());
And here is the nested routers with the router prefix, which is not working:
var forums = new Router({ 'prefix': '/forums' }); var posts = new Router({ 'prefix': '/:fid/posts' }); posts.get('/', function *() { this.body = 'posts' }); posts.get('/:pid', function *() { this.body = 'post' }); forums.use(posts.routes()); // OR forums.use('/', posts.routes()); app.use(forums.routes());
Could you please suggest or help me here. Thanks in advance.
The text was updated successfully, but these errors were encountered:
Try this: forums.use('', posts.routes()); It is strange, but AFAIK it is only way.
forums.use('', posts.routes());
Sorry, something went wrong.
Thanks!
I just encountered this too, it's a bug imo.
883c1af
Default router middleware without path to root.
bafe278
- Fixes ZijianHe#161, fixes ZijianHe#155, fixes ZijianHe#156. - Removes dependency on koa-compose.
No branches or pull requests
I tried to explore the nested routers by adding the router prefix in it, but it responds with the status code 404.
Here is working example without adding the router prefix:
And here is the nested routers with the router prefix, which is not working:
Could you please suggest or help me here. Thanks in advance.
The text was updated successfully, but these errors were encountered: