404 Not found, when middleware is undefined #3902
Unanswered
Durounseki
asked this question in
Q&A
Replies: 1 comment 1 reply
-
We can make simple reproduction code. import { Hono } from 'https://esm.sh/hono'
const app = new Hono();
app.get('/test', undefined, (c) => c.text("Hono is hot"));
export default app; |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, while working on my app, that uses Hono with a Cloudflare worker, I found some behaviour that appeared strange to me. The following is a simplified example of my codebase
When I send a "GET" request to "/test1" I get a 404 Not Found Error, but when I send a "GET" request to "/test2", "testing..." is logged to the console and I get "passed!" on the response. At the beginning I thought hoisting would prevent this issue, but then I realised that by using
const test = async (c,next)...
instead ofasync function test(c,next)...
I was preventingtest
from being hoisted. When I change the definition of test then both endpoints work.It still caught my attention that the '/test1' endpoint is not registered when the middleware test is undefined. Is this the intended behaviour?
Beta Was this translation helpful? Give feedback.
All reactions