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
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
GitHub - ionic-team/rollup-plugin-node-polyfills
Contribute to ionic-team/rollup-plugin-node-polyfills development by creating an account on GitHub.
5 Replies
Hello, I’m Allie!
serveStatic for Hono has been deprecated, and the recommendation is now to use Pages for your Hono app and your static assets
Cloudflare Docs
Cloudflare Pages documentation · Cloudflare Pages docs
Deploy your Pages project by connecting to your Git provider, uploading prebuilt assets directly to Pages with Direct Upload or using C3 from the …
Fuming
FumingOP8mo ago
Then, would it be possible to have the backend in workers as an api and consume it from a frontend deployed in pages? Or is this not possible? I'm quite lost as how are we suposed to use this service... :(
Hello, I’m Allie!
You could, but you don't need to. The backend can be deploy as an Advanced Mode Function, instead of needing to create a separate Worker
Cloudflare Docs
Advanced mode · Cloudflare Pages docs
Advanced mode allows you to develop your Pages Functions with a _worker.js file rather than the /functions directory.
Hello, I’m Allie!
Functions, in this case, are basically Workers, just tied to a Pages Project They have a few other differences, but that's the basic idea
Fuming
FumingOP8mo ago
Oh, okey, I see, thanks!!
Want results from more Discord servers?
Add your server