Skip to content
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

root option for serveStatic on Windows #3693

Open
oscarotero opened this issue Nov 20, 2024 · 0 comments
Open

root option for serveStatic on Windows #3693

oscarotero opened this issue Nov 20, 2024 · 0 comments
Labels

Comments

@oscarotero
Copy link

oscarotero commented Nov 20, 2024

What version of Hono are you using?

4.6.11

What runtime/platform is your app running on? (with version if possible)

Deno

What steps can reproduce the bug?

I'm using this middleware in this project to serve static files from a directory specified with the root option: https://github.com/lumeland/cms/blob/main/adapters/lume.ts#L124-L129

The site.dest() returns the absolute path of the root folder. In Linux/Mac it has the format /foo/bar. In Windows is C:/foo/bar (note the /separator instead of \, since Windows supports both separators (I think it's not relevant here, but just in case).

This works fine in Linux and Mac but not in Windows (issue: lumeland/cms#34)

What is the expected behavior?

I expect the root variable interpreted as an absolute path to the base folder.
Inspecting the code here looks like it's not always treated as absolute path, only if the path starts with / (which is not compatible with Windows).

What do you see instead?

404 errors for all requests

Additional information

This is a breaking change introduced in Hono in the version 4.6.3 (this is the PR with more info: #3420)
Previously, the relative path was passed but this stopped working after upgrading Hono so I had to change it (commit here: lumeland/cms@v0.6.4...v0.6.5)

@yusukebe yusukebe added bug and removed triage labels Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants