honojs / node-server

Node.js Server for Hono
https://hono.dev
349 stars 44 forks source link

add support for absolute path to serveStatic root #187

Open charlyoleg2 opened 4 weeks ago

charlyoleg2 commented 4 weeks ago

Could you add support for absolute path for the root of the serveStatic? In my use-case designix-uis, an absolute path to the folder containing the static files is required as tool can be called from any directory. Currently i"m using Express, but i"d like to replace it with Hono and this feature is missing. The following patch in the file src/serve-static.ts might be sufficient for supporting the absolute path:

-      path = addCurrentDirPrefix(path)
+      if (!/^\//.test(path)) {
+        path = addCurrentDirPrefix(path)
+      }
yusukebe commented 3 weeks ago

Hi @charlyoleg2

We may add supporting it.

Related to: https://github.com/honojs/hono/pull/3108 https://github.com/honojs/node-server/pull/78

DoWhileGeek commented 3 weeks ago

@yusukebe I just ran into the absolute path issue as well 😅