Skip to content

fix: use relative path for serveStatic root#10

Open
oginokairan wants to merge 1 commit intodev1from
fix/serve-static-relative-root
Open

fix: use relative path for serveStatic root#10
oginokairan wants to merge 1 commit intodev1from
fix/serve-static-relative-root

Conversation

@oginokairan
Copy link
Contributor

Summary

  • @hono/node-server/serve-static does not support absolute paths for the root option
  • The internal getContent function prepends ./, turning /app/dist/client into ./app/dist/client (resolved relative to cwd as /app/app/dist/client)
  • This causes all static file lookups to fail, falling through to the SPA fallback which returns text/html for JS/CSS files, blocking browser execution
  • Fix: use path.relative() to produce a cwd-relative path like dist/client

Test plan

  • Deploy and verify static assets (JS, CSS) are served with correct Content-Type headers
  • Verify SPA routing still works for non-static paths

🤖 Generated with Claude Code

@hono/node-server/serve-static does not support absolute paths for the
root option. The internal getContent function prepends "./" which turns
an absolute path like /app/dist/client into ./app/dist/client (relative
to cwd), causing file lookups to fail. Requests then fall through to the
SPA fallback which returns text/html, blocking JS execution in browsers.

Use path.relative() to convert to a cwd-relative path (e.g. dist/client).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@oginokairan oginokairan requested a review from atsuki44 March 9, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant