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:
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
serveStatic
for Hono has been deprecated, and the recommendation is now to use Pages for your Hono app and your static assetsCloudflare 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 …
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... :(
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.
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
Oh, okey, I see, thanks!!