Serve images and video from Cloudflare R2 instead of the repo - #177
Merged
Conversation
Deploying with
|
| 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
force-pushed
the
feat/r2-image-video-cdn
branch
from
August 6, 2026 09:25
c9e7c2c to
cffa1da
Compare
dborovcanin
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
public/, bloating every PR that touched them and the repo's clone size over time. They're now stored in the sharedwebsites-imagesR2 bucket and served through two on-demand routes (src/pages/img,src/pages/video, sharingsrc/lib/r2-proxy.ts) that keep the existing/img/...and/video/...URLs unchanged — no component, blog frontmatter, orsrc/data/*.tsreference needed to change.wrangler.jsonc'sIMAGES_BUCKETR2 binding and the two proxy routes.scripts/publish-image.mjs(maintainer-only — seescripts/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.public/partners/intopublic/img/partners/and repointsPartners.astro, since it's the same category of asset as everything else underimg/.public/img/andpublic/video/now that every file that was actually referenced fromsrc/(298, after pruning 51 that turned out to be unused — verified by cross-referencing every image against every component, page, blog post, andsrc/data/*.tsfile) has been uploaded to R2 and spot-checked byte-for-byte against the originals.Test plan
pnpm format:check,pnpm lint,pnpm check,pnpm buildall pass locally withpublic/img/andpublic/video/removed--remote) R2 bucket via the Wrangler CLI, 0 failuresIMAGES_BUCKETbinding to be present on the preview environment)