Make published R2 images visible in local dev (stacked on feat/r2-image-cdn) - #16
Open
ianmuchyri wants to merge 1 commit into
Open
Make published R2 images visible in local dev (stacked on feat/r2-image-cdn)#16ianmuchyri wants to merge 1 commit into
ianmuchyri wants to merge 1 commit into
Conversation
Add "remote": true to the IMAGES_BUCKET R2 binding in wrangler.jsonc so `wrangler dev` connects to the real "websites-images" bucket instead of an empty local simulator -- images published via publish-image.mjs now render locally without manually seeding local R2 state. Bump the wrangler devDependency ^4.95.0 -> ^4.120.0: the older version has a bug where a remote R2 binding throws "SyntaxError: Unexpected end of JSON input" instead of proxying to R2, which is what made this look broken in the first place. Document in scripts/README.md that `wrangler dev` (not `wrangler pages dev`) is the correct local preview command -- this repo deploys via plain `wrangler deploy` (Workers + static assets), not Pages, so `pages dev` silently drops the R2 binding entirely.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
hardware-docs | ecd130c | Commit Preview URL Branch Preview URL |
Aug 07 2026, 04:58 PM |
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.
Stacked PR — depends on #feat/r2-image-cdn
This branches off
feat/r2-image-cdn(notmain) because that branch — which introduces thewrangler.jsoncr2_bucketsbinding,scripts/publish-image.mjs,scripts/README.md, and the image-proxy Worker — is not yet merged. This PR cannot merge beforefeat/r2-image-cdndoes, and should be reviewed with that in mind (the diff below is only the incremental fix on top of it).Follow-up to the equivalent fix already shipped in magistrala-docs: absmach/magistrala-docs#171
Summary
"remote": trueto theIMAGES_BUCKETR2 binding inwrangler.jsoncsowrangler devconnects to the realwebsites-imagesbucket instead of an empty local simulator — images published viapublish-image.mjsnow render locally without manually seeding local R2 state. Confirmed via the installed wrangler's ownconfig-schema.jsonthat this field is local-dev-only and has no effect on the deployed Worker.wranglerdevDependency^4.95.0→^4.120.0(and updatepnpm-lock.yamlaccordingly): the older version has a bug where a remote R2 binding throwsSyntaxError: Unexpected end of JSON inputinstead of actually proxying to R2, which is what made this look broken in the first place.scripts/README.md(right after "Publishing an image") documenting thatwrangler dev— notwrangler pages dev— is the correct local preview command, since this repo deploys via plainwrangler deploy(Workers + static assets), not Pages.Test plan
pnpm run build && npx wrangler dev(withCLOUDFLARE_ACCOUNT_IDset to the account owningwebsites-images, since the token has access to more than one account) — startup banner showsenv.IMAGES_BUCKET (websites-images) R2 Bucket remote, confirming binding mode is remote, not local/) returns 200 (redirects to/docs/hardware/)/img/<file>MDX convention acrosscontent/docs/**return 200 with correctimage/png/image/svg+xmlcontent and byte-identical payload to a directwrangler r2 object get --remotedownload (verifiedbaseboard-front.png, 119040 bytes)SyntaxError: Unexpected end of JSON inputat any point./node_modules/.bin/wrangler --versionreports4.120.0afterpnpm installNotes for reviewers
origin/feat/r2-image-cdnbranch does not use aNOISSUE -commit prefix (unlike some other commits in this repo's history), so this PR's commit message matches that branch's own two commits' plain style.content/docs/s0-gateway/{index,pinouts,architecture}.mdx) still reference images via the old relative../images/*.pngconvention rather than the new/img/*R2 convention — pre-existing onfeat/r2-image-cdn, out of scope for this fix.