cloudflare workers handler for proxying requests to backblaze b2
this package enables using backblaze b2 as a back end for a website served via cloudflare workers. within certain limits, this is completely free! the bandwidth alliance as well as generous free-tier limits from backblaze and cloudflare make this possible.
yarn add cloud-blaze
import the handler into your cloudflare workers code
import b2ProxyHandler from "cloud-blaze";
addEventListener("fetch", (event) => {
event.respondWith(b2ProxyHandler({ event }));
});
- setup cloudflare dns
- upload static files to b2
- deploy to cloudflare workers
wrangler publish -e <env>
- set bucket key and bucket key id as secret environment variables
wrangler secret put -e <env> <VAR_NAME>
B2_APPLICATION_KEY
: b2 application key to access private bucketB2_APPLICATION_KEY_ID
: b2 application key idB2_BUCKET_PREFIX
: b2 bucket prefix for serving files within a bucket folderPUBLIC_PREFIX
: public url prefix to proxy requests behind a certain pathname
bucketKey
: defaults toB2_APPLICATION_KEY
bucketKeyId
: defaults toB2_APPLICATION_KEY_ID
bucketPrefix
: defaults toB2_BUCKET_PREFIX
publicPrefix
: defaults toPUBLIC_PREFIX
- edge SSR + B2 bucket hosting