Closed artecoop closed 3 years ago
Hello !
By now, I hope you figured it out.
But if not and regarding your use case, I will take a look to koa-jwt, a middleware for validating JSON Web Tokens.
It should work with @koa/router.
I believe this issue can be closed as the resolution was given by @niftylettuce over on #101
Hello! (Pay attention: typescript ahead!) I have a simple server in Koa and I just updated router to it's latest version and naming convention (from koa-router": "8.0.8").
Before any route is resolved, I need to check if the context's request has a token. If so, I transform the token to an object and pass it back in the context's state:
the entry point for the Koa server is
Because ordering matters in koa router, all the routes defined after the
SERVER.use(auth.routes())
are parsed afterauth.all(...)
. Note that public routes are unaffected.Now the problem is that after the upgrade, every "hidden" route throws 404. Debugging my server show me that hit the
auth.all
correctly, but thenext()
seems to throw the request into the void.Any clue on my error?