Skip to content

Serve images and video from Cloudflare R2 instead of the repo - #177

Merged
dborovcanin merged 1 commit into
mainfrom
feat/r2-image-video-cdn
Aug 6, 2026
Merged

Serve images and video from Cloudflare R2 instead of the repo#177
dborovcanin merged 1 commit into
mainfrom
feat/r2-image-video-cdn

Conversation

@ianmuchyri

@ianmuchyri ianmuchyri commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Images and video were committed straight into public/, bloating every PR that touched them and the repo's clone size over time. They're now stored in the shared websites-images R2 bucket and served through two on-demand routes (src/pages/img, src/pages/video, sharing src/lib/r2-proxy.ts) that keep the existing /img/... and /video/... URLs unchanged — no component, blog frontmatter, or src/data/*.ts reference needed to change.
  • Adds wrangler.jsonc's IMAGES_BUCKET R2 binding and the two proxy routes.
  • Adds scripts/publish-image.mjs (maintainer-only — see scripts/README.md) to upload a single image/video and purge the edge cache for it immediately, plus the reasoning for why only maintainers hold the credential.
  • Consolidates public/partners/ into public/img/partners/ and repoints Partners.astro, since it's the same category of asset as everything else under img/.
  • Removes public/img/ and public/video/ now that every file that was actually referenced from src/ (298, after pruning 51 that turned out to be unused — verified by cross-referencing every image against every component, page, blog post, and src/data/*.ts file) has been uploaded to R2 and spot-checked byte-for-byte against the originals.

Test plan

  • pnpm format:check, pnpm lint, pnpm check, pnpm build all pass locally with public/img/ and public/video/ removed
  • All 298 files uploaded to the real (--remote) R2 bucket via the Wrangler CLI, 0 failures
  • 5 spot-checked files (logos, nested blog images, partners, both video files) diff byte-for-byte identical between the original repo file and what's stored in R2
  • Confirm images/video actually render correctly on this PR's preview deployment (this is the first real end-to-end test of the routes against a deployed Worker — needs the IMAGES_BUCKET binding to be present on the preview environment)
  • Spot-check a few pages that use heavier image sets (blog posts, solutions pages) on the preview before merging

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
absmach-website cffa1da Commit Preview URL

Branch Preview URL
Aug 06 2026, 09:26 AM

Images and video were committed straight into public/, bloating every
PR that touched them and the repo's history over time. They're now
stored in the shared "websites-images" R2 bucket and served through
two on-demand routes (src/pages/img and src/pages/video, sharing
src/lib/r2-proxy.ts) that keep the existing /img/... and /video/...
URLs working unchanged, so no component, blog frontmatter, or
src/data/*.ts reference needed to change.

- Add R2 binding (wrangler.jsonc) and the two proxy routes
- Add scripts/publish-image.mjs (maintainer-only) to upload + purge
  the edge cache for a single image or video; see scripts/README.md
- Consolidate public/partners/ into public/img/partners/ and repoint
  Partners.astro, since it's the same category of asset
- Remove public/img/ and public/video/ now that every file in them
  (298, after pruning 51 that were already unused) has been uploaded
  to R2 and spot-checked against the originals
@ianmuchyri
ianmuchyri force-pushed the feat/r2-image-video-cdn branch from c9e7c2c to cffa1da Compare August 6, 2026 09:25
@dborovcanin
dborovcanin merged commit d566318 into main Aug 6, 2026
2 checks passed
@dborovcanin
dborovcanin deleted the feat/r2-image-video-cdn branch August 6, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants