Coder Social home page Coder Social logo

boourns / b2-remove-prefix Goto Github PK

View Code? Open in Web Editor NEW

This project forked from phistrom/b2-remove-prefix

0.0 1.0 0.0 5 KB

A CloudFlare Worker for removing the /file/bucket-name/ part of a B2 bucket domain

License: The Unlicense

JavaScript 100.00%

b2-remove-prefix's Introduction

B2 Remove Prefix Worker

A CloudFlare worker script that removes the /file/{bucket-name}/ portion of the URL when access a B2 Bucket.

  • Works with the free tier of CloudFlare and CloudFlare Workers
  • It's still free egress from your B2 bucket
  • No performance penalty, just prettier URLs for your B2 assets
  • Doesn't expose the name of your B2 bucket in the URL

Why

If you followed this guide to set up a CloudFlare domain in front of Backblaze B2, you may have been disappointed by the length of the URL.

For instance, let's say you set up i.example.com as a proxied CNAME on CloudFlare in front of f001.backblazeb2.com. Then for you to download a file called /test.txt in the root of the bucket example-bucket, the URL would be https://i.example.com/file/example-bucket/test.txt. By putting this Worker script in front of it, your URL becomes a simple https://i.example.com/test.txt.

License

The Unlicense

Installation

  1. Use wrangler to generate a new app
wrangler generate myapp https://github.com/phistrom/b2-remove-prefix
  1. Overwrite the wrangler-generated wrangler.toml with a copy of wrangler.toml.example.
  2. Fill in zone_id, account_id, and routes fields as usual in wrangler.toml
  3. Also set the B2_BUCKET_NAME under [vars] in wrangler.toml to your B2 bucket name
  4. Upload to the routes you specified with wrangler publish

Alternatively, you could also just copy and paste the code from index.js into the Quick Edit editor in your CloudFlare dashboard. Just be sure to also set the B2_BUCKET_NAME and CF_CACHE_TTL environment variables for this Worker by going into its settings.

b2-remove-prefix's People

Contributors

phistrom avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.