Skip to content
New issue

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

Multi routes will be called if the last middleware call next() #520

Open
jiladahe1997 opened this issue Jan 18, 2020 · 0 comments
Open

Multi routes will be called if the last middleware call next() #520

jiladahe1997 opened this issue Jan 18, 2020 · 0 comments

Comments

@jiladahe1997
Copy link

node.js version: v12.9.0

npm/yarn and version: 6.10.2

koa-router version: 7.4.0

koa version: 2.11.0

Code sample:

router.get("/", async (ctx, next) => {
  console.log("match /");
  await next();
  ctx.body = "Hello";
});
router.get("/*", ctx => {
  console.log("match /*");
});

Expected Behavior:

match /

Actual Behavior:

match /
match /*

Additional steps, HTTP request details, or to reproduce the behavior or a test case:

I'm new to Koa2, and I have misused next() in the last middleware. I don't think this will do anything and return , but actual it do something, it calls the next route.

I think that is strange, and I'm not sure if it's a bug.

I think this means I can not use most third Community middlewares as the last one, beacause they will call next().

Thanks for reading , a simple demo is here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant