How do I return a HTML? Hono ts

Hi!

I've been trying to return a HTML file on my worker. That HTML is saved in on another file. I need to read it in some way so I can return it using c.html() (Hono way of returning HTML). I've tried reading the file using node, however I get this error message:

Enabling Node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details.

Is there any way of returning that index.html file from that endpoint, without using node?

Folder structure:

public/
  • views/
  • - index.html
    src/
  • index.ts
Index.ts:

import { Hono } from 'hono'
import { serveStatic } from 'hono/cloudflare-workers'

const app = new Hono()

app.get('/public/*', serveStatic({
  root: './',
  manifest: ''
}))

app.get('/', (c) => {
  try {
    return c.html(landingpage);
  } catch (err) {
    return c.text('Internal Server Error', 500)
  }
})

export default app
GitHub
Contribute to ionic-team/rollup-plugin-node-polyfills development by creating an account on GitHub.
Was this page helpful?
How do I return a HTML? Hono ts - Cloudflare Developers