Best way to serve static assets using hono?

I want to create an endpoint (for ex endpoint.com/script.js) that serves a script file. right now, im returning the contents of the file directly by
return c.text(scriptContent, 200, {
'Content-Type': 'application/javascript'
});
return c.text(scriptContent, 200, {
'Content-Type': 'application/javascript'
});
i was wondering if there was an easier way to directly serve the static file by name
2 Replies
James
James4w ago
Take a look at the Hono docs for serving static assets using Workers Assets: https://hono.dev/docs/getting-started/cloudflare-workers#serve-static-files
Cloudflare Workers - Hono
Web framework built on Web Standards for Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Node.js, and others. Fast, but not only fast.
pepe-le-moko
pepe-le-moko3w ago
if I can piggyback on this question: is it possible to set Cache-Control headers on these static assets? (in the code, not through the cloudflare dashboard)
Want results from more Discord servers?
Add your server