honojs / honox

HonoX - Hono based meta framework
https://hono.dev
MIT License
1.4k stars 38 forks source link

_middleware.ts in param router doesn't trigger #184

Closed joefitter closed 3 months ago

joefitter commented 3 months ago

What version of HonoX are you using?

0.1.12

What steps can reproduce the bug?

  1. add a _middleware.ts file with a simple console.log 1 level deep in routes/subroute/_middleware.ts
  2. navigate to /subroute - log is shown as expected
  3. add a _middleware.ts with a console.log in routes/subroute/[id]/_middleware.ts
  4. navigate to /subroute/id - subroute middleware log is shown as expected, new log is not shown.

Nested non-parameter folders work as expected - eg /foo/bar/_middleware.ts

What is the expected behavior?

The _middleware.ts should be run before all routes and sub routes in the directory

What do you see instead?

It doesn't trigger at all for any parameter folders ([id])

Additional information

No response

EdamAme-x commented 3 months ago

Honox recognizes middeware and is therefore other reason. I will take a look.

https://github.com/honojs/honox/blob/9139576f01c82511b5846b364ba6978f050abed4/src/server/with-defaults.ts#L26

EdamAme-x commented 3 months ago

https://github.com/honojs/honox/blob/9139576f01c82511b5846b364ba6978f050abed4/src/server/server.ts#L135-L143

yusukebe commented 3 months ago

Hi @joefitter

Thanks for your report! I've fixed it and released the new version v0.1.20 which includes the change. Try it!

joefitter commented 3 months ago

great stuff, thanks for sorting it so quickly