-
Notifications
You must be signed in to change notification settings - Fork 405
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
Allowed methods broken in 5.2.0, 5.2.1 #182
Comments
@alexmingoia Many thanks! |
Hi @alexmingoia Imho, this should not be an issue. The "privateRouter" above uses a middleware without methods and paths, which should be treated as a middleware mounted on root and should be dispatched for all requests. I mean this is quite reasonable . After applying this fix, the koa-static middleware mounted on a certain path in my app with koa-router is skipped like air. That's because all middlewares without an upcoming explicit method call (e.g. router.get/router.post/router.del...) are bypassed by the .route boolean check in the fix and will no longer be dispatched. BTW, for the same reason, below example in your README will not work anymore. I just wonder which behavior better matches your original design. If I am wrong, please feel free to correct me. router // use middleware only with given path // or with an array of paths app.use(router.routes()); |
@alexmingoia I would agree with @rockie. Removing this line(I mean condition) will help us avoiding lots of forks of koa-router |
I have an app that has "private" and "public" routers. When a request arrives at a route defined on the public router, but using a method (e.g. DELETE) defined on the router, it falls through to the private router in
5.2.0
,5.2.1
. Versions5.0.1
,5.1.0
, and5.1.1
exhibit the expected behavior.Environment:
Ubuntu
15.04
node.js
4.0.0
koa
1.0.0
Expected:
DELETE
http://localhost:3000/v1/public
should return a405
Method Not Allowed
.Working in version
5.0.1
. Broken in5.2.0
and5.2.1
.Actual:
DELETE
http://localhost:3000/v1/public
returns a401
Unauthorized
👎 because it falls through to the private router despite usingapp.use(publicRouter.allowedMethods())
.Reproduce:
To reproduce, run this with the versions mentioned above.
If I am doing something incorrectly or if this is working as designed, please let me know. Thanks!
The text was updated successfully, but these errors were encountered: