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

serveStatic does not work when set absolute path to root #3107

Closed
oon00b opened this issue Jul 7, 2024 · 2 comments · Fixed by #3420
Closed

serveStatic does not work when set absolute path to root #3107

oon00b opened this issue Jul 7, 2024 · 2 comments · Fixed by #3420
Labels
enhancement New feature or request.

Comments

@oon00b
Copy link
Contributor

oon00b commented Jul 7, 2024

What version of Hono are you using?

4.4.12

What runtime/platform is your app running on?

Deno and Bun

What steps can reproduce the bug?

This is minimal script to reproduce the bug. This script can be executed with deno run --allow-net --allow-read command.

import { Hono } from "jsr:@hono/hono@^4.4.12";
import { serveStatic } from "jsr:@hono/hono@^4.4.12/deno";

const app = new Hono();

app.use(
    "*",
    serveStatic({
        root: "/tmp/public_html"
    })
);

Deno.serve(app.fetch);

The directory structure of /tmp/public_html/:

/tmp/public_html/
└── index.html

/tmp/public_html/index.html:

<p>test</p>

When accsessing http://localhost:8000, the server returns 404 Not Found and outputs an error:

NotFound: No such file or directory (os error 2): open './tmp/public_html/index.html'
NotFound: No such file or directory (os error 2): open './tmp/public_html/'

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

@ckken
Copy link

ckken commented Jul 11, 2024

+1

@cj-1010-1414
Copy link

Same here. Just tried on Bun. serveStatic doesn't serve file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request.
Projects
None yet
4 participants