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

Updates hono-entry.node.ts to serve static files from public directory #452

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

vitalybaev
Copy link
Contributor

Fixes #451

As mentioned in the issue, project with Hono doesn't serve static files that they put to the public/ directory.
After some investigation, turns out that in hono-entry.node.ts there are these lines:

nodeApp.use(
  '/assets/*',
  serveStatic({
    root: './dist/client/',
  }),
);

Because of these lines, Vike app files are served correctly, because they are in ./dist/client/assets/ directory, but if I had file under public/logo.svg, during build it will be copied to ./dist/client/logo.svg and Hono lacks routing rule for that.

This PR changes pattern from assets/* to just /*, it matches both cases, so that all files from the public directory start serving normally as well as /assets dir is resolved

@magne4000
Copy link
Member

Makes sense, thanks!

@magne4000 magne4000 merged commit be84ec0 into vikejs:main Jan 13, 2025
11 of 12 checks passed
@vitalybaev vitalybaev deleted the patch-1 branch January 13, 2025 08:22
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.

Project with Hono breaks serving files from public/ directory
2 participants