Open staniboy opened 3 months ago
@staniboy You can check https://github.com/honojs/hono/pull/3108#issuecomment-2225636805 and PR https://github.com/honojs/hono/pull/3108, https://github.com/honojs/node-server/pull/78
For workaround, you can do something like below
// for client
app.get("*", serveStatic({ root: `${relative(process.cwd(), __dirname)}/../client/dist/` }));
app.get("*", serveStatic({ path: `${relative(process.cwd(), __dirname)}/client/dist/index.html` })); // fallback
// for public
app.get("*", serveStatic({ root: `${relative(process.cwd(), __dirname)}/public/` }));
app.get("*", serveStatic({ path: `${relative(process.cwd(), __dirname)}/public/index.html` })); // fallback
If you use ES modules then instead of using __dirname
you can use import.meta.dirname
Duplicate #2200
Regarding this problem, it's not an actual bug, but we have to consider to solve it.
Related to https://github.com/honojs/hono/pull/3420
This issue has been marked as stale due to inactivity.
What version of Hono are you using?
4.5.4
What runtime/platform is your app running on?
Bun
What steps can reproduce the bug?
This will serve the root from client/dist and display index.html but will fail to trigger fallback to index.html when non existing path is specified.
I've then moved my client build inside of server project folder and used:
in this case fallback worked properly.
What is the expected behavior?
Fallback path with parent directory working
What do you see instead?
Fallback path with parent directory not working
Additional information
No response