Engineering Case Study

Building a 5GB Video-to-URL Service on Cloudflare Workers, R2, and MCP

Turning an MP4, MOV, WebM, or MKV recording into a shareable URL sounds straightforward until edge HTML caching, gigabyte-scale uploads, and developer authentication collide in production. Here are the exact bottlenecks we found and fixed on Video2URL.

1. Why Cloudflare Edge HTML Caching Silently Bypassed Marketing Pages

On SSR Workers, anonymous GET requests to /pricing and landing pages were returning cache-control: no-store, must-revalidate. Two subtle layers triggered the bypass: default next-intl middleware emitted Set-Cookie: NEXT_LOCALE=en even with localeDetection disabled, and reading headers() for per-origin robots metadata caused the runtime to stamp no-store, must-revalidate.

// Keep marketing pages stateless so CDN edge caches serve anonymous visitors cleanly
const intlMiddleware = createMiddleware({
  ...routing,
  localeCookie: false,
});

By disabling localeCookie on stateless marketing routes and allowing framework-level no-store, must-revalidate (while strictly rejecting private, explicit no-store, or Cookie headers), anonymous hits now serve directly from Cloudflare edge cache with s-maxage=300.

2. Scaling from 50MB Single PUTs to 5GB R2 Multipart Resumable Uploads

Screen recordings and 4K MOV clips routinely cross 100MB. Using presigned R2 multipart uploads keeps video bytes completely out of Worker memory while letting us offer 100 MB on Free, 1 GB on Pro, and 5 GB on Business alongside optional custom CNAME domains.

3. Passwordless Cloudflare Email OTP + GitHub OAuth for Developer & MCP Workflows

Requiring Google OAuth blocked corporate email users and CLI/MCP developers. Pairing GitHub OAuth with Better Auth emailOTP over Cloudflare Workers send_email bindings delivers 6-digit HMAC-hashed verification codes directly from the edge with zero external email SaaS dependencies.

import { Video2URL } from 'video2url';

const client = new Video2URL({ apiKey: process.env.VIDEO2URL_API_KEY! });
const result = await client.uploadFromUrl('https://example.com/demo-recording.mp4', {
  filename: 'demo-recording.mp4',
  share: { visibility: 'unlisted' },
});
console.log(result.url);