node-server icon indicating copy to clipboard operation
node-server copied to clipboard

serveStatic isn't working

Open ibnumusyaffa opened this issue 2 years ago • 2 comments

serve static is not working, iam not using absolute path, minimal repro https://github.com/ibnumusyaffa/hono-serve-static-not-working

ibnumusyaffa avatar Dec 31 '23 03:12 ibnumusyaffa

image

ibnumusyaffa avatar Dec 31 '23 03:12 ibnumusyaffa

Hi @ibnumusyaffa

Thank you for creating the issue.

You can do what you want to do with the following code:

app.get(
  "/static/*",
  serveStatic({
    root: "./storage",
    rewriteRequestPath: (path: string) => path.replace(/^\/static/, ""),
  })
)

I would like to introduce onNotFound() because the current implementation of @hono/node-server is difficult to debug when a file is not found.

yusukebe avatar Jan 01 '24 14:01 yusukebe

This can be closed. Thanks!

yusukebe avatar Sep 30 '24 08:09 yusukebe