honojs / hono

Web framework built on Web Standards
https://hono.dev
MIT License
18.25k stars 515 forks source link

Deprecate `serveStatic` for Cloudflare Workers #2580

Closed yusukebe closed 4 months ago

yusukebe commented 4 months ago

Cloudflare Workers Site, which is used in serveStatic in hono/cloudflare-workers, is now deprecated.

https://developers.cloudflare.com/workers/configuration/sites/

If you want to create an application that serves asset files, you must use Cloudflare Pages. So, following this, we have to make serveStatic in hono/cloudflare-workers deprecated.

yusukebe commented 4 months ago

This is closed by #2583

timfish commented 4 months ago

What if I was never using "cloudflare sites" and instead just wanted to serve some static assets from a worker?

cometkim commented 4 months ago

What if I was never using "cloudflare sites" and instead just wanted to serve some static assets from a worker?

Use R2 with Cache API. Here's an example: https://github.com/daangn/websites/blob/main/_workers/about-daangn-com-production/functions/serve.ts

cometkim commented 4 months ago

In most cases even this is not necessary. Using Cloudflare Pages as-is does not add any additional cost for Functions and R2 calls.

I need this for my heavily customized build-deployment pipeline.

yusukebe commented 4 months ago

Or you can use import, if you have a small number of files you want to publish:

https://developers.cloudflare.com/workers/wrangler/configuration/#importing-assets-within-a-worker