Worker breaks mp4 files

Update (likely for my future self!): I was able to fix it via the following. There is likely a cleaner solution.:

  1. Create a Custom Domain for the Worker. (Main account page → Workers → Select your Worker → Triggers → Add Custom Domain) I used a new subdomain (e.g. video.example.com). Wait for the Custom Domain to be ready.

  2. Fix B2 Bucket rules by tweaking them slightly. Add the actual subdomain you want to use to the Backblaze Transform rule:
    "And", "Hostname", "Starts with" v.example.com

  3. Create Cache Rule to prevent Cloudflare from caching the videos:
    Caching → Cache Rules → Create Rule

  • URI Path, Ends With, ".mp4" -> Bypass Cache
  • Add any other file types you use for video.
  1. Create a Page Rule forwarding from the Custom/Worker Domain to your chosen subdomain.
    Rules -> Page Rules -> Create Rule
  • Set URL to the Custom Domain:
    video.example.com

  • Setting:
    Forwarding URL

  • Enter destination URL:
    https://v.example.com

  • Optionally, you can add a wildcard (*) to the Page Rule URL and a reference ($1) to the end of the destination URL. This runs your Worker on any requests sent to video.example.com then forward the modified request to v.example.com.

Original post:
If a Worker is enabled, I get a 404 error when loading an uncached video file from a Backblaze B2 bucket. (My understanding is serving videos from B2 buckets is allowed as long as they are not cached by CF.) Strangely, loading images from the same bucket works without issue. I double-checked the filename and even uploaded a different, sample file to the same result. Checking real-time Worker logs shows an “Ok” status and a GET trigger. The URL looks OK in the logs.

The Worker is setting CSP headers. The Worker sets the headers correctly for images. Disabling the Worker route causes the video to load.

Any help/feedback on this would be appreciated!