donavon / remix-etag

MIT License
70 stars 3 forks source link

feat: Node environment-dependent etag generation changed to etag generation using WebAPI Crypto #1

Open himorishige opened 2 years ago

himorishige commented 2 years ago

Hello.

Thank you for the very useful article and library.

I am using Remix in a Cloudflare Workers and was not able to use remix-etag in a Cloudflare Workers environment because the etag package that remix-etag uses depends on crypto.(Crypto doesn't work with Cloudflare Workers.)

https://developer.mozilla.org/en-US/docs/Web/API/Crypto https://community.cloudflare.com/t/set-etag-in-worker/178881

So, I changed the crypto part used by etag to use WebAPI Crypto, which I think is better suited for Remix users. For example, how about this implementation?

matthova commented 1 year ago

I've been using this PR in a cloudflare remix site and it's been great 🎉 https://github.com/matthova/remix-cloudflare-pages-etag-repro/blob/main/package.json#L23

Live example site here: https://remix-cloudflare-pages-etag-repro.pages.dev/