-
-
Notifications
You must be signed in to change notification settings - Fork 630
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
Error c.res.status of 404 in middlewareHandler before next() #3788
Comments
This is not a bug. |
Thanks, but how to know the route exists? eg fastify support the fastify.addHook('onRequest', async function (request, reply) {
if (request.is404) {
// I can do something
}
} |
You have |
@MathurAditya724 Sorry, this might not be my usage scenario of app.use(async (c, next) => {
if (request.is404) {
// not to verify jwt
return next
}
// verify jwt
const token = c.req.header('authorization')
const res = jwt.verify(token)
if(!res.verified){
return c.text("", 401)
}
await next()
}) |
In the |
@MathurAditya724 Thanks, but Is there a way to get the original URL from the request? It cannot match req.path and route.path // routes
[{
path: "/user/:id",
method: "ALL",
handler: [AsyncFunction],
}]
// but c.req.routePath and c.req.path
// '/*' '/user/1' |
You can get the URL for the request like this - |
Sorry, but it seem like console.log(c.req.method, c.req.routePath, c.req.path, c.req.url)
|
I think we should take this discussion on Discord, that way more people can take a look at this and can help. And close this issue here. |
Yes. |
What version of Hono are you using?
4.6.14
What runtime/platform is your app running on? (with version if possible)
bun
What steps can reproduce the bug?
What is the expected behavior?
Try curl
What do you see instead?
Try curl
Additional information
No response
The text was updated successfully, but these errors were encountered: