Skip to content
Discussion options

You must be logged in to vote

You can use serveStatic from Hono to achieve that.

Something like this:

// Serve static files like images, css, js from the ./public folder when accessing /web
app.use('/web/*', serveStatic({ root: './public' }))

// If no specific file is found under /web, serve the default index.html
app.get('/web/*', serveStatic({ path: './public/index.html' }))

// For API routes
app.get('/api/test', (c) => {
  return c.json({ message: 'Healthy!' })
})

You can read more about it here: https://hono.dev/docs/getting-started/nodejs#serve-static-files

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Serhioromano
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants