Skip to content

Make published R2 images visible in local dev - #46

Open
ianmuchyri wants to merge 1 commit into
mainfrom
fix/local-dev-r2-remote-binding
Open

Make published R2 images visible in local dev#46
ianmuchyri wants to merge 1 commit into
mainfrom
fix/local-dev-r2-remote-binding

Conversation

@ianmuchyri

Copy link
Copy Markdown
Contributor

Summary

  • 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.115.0 -> 4.120.0: the older version has a bug where a remote R2 binding throws SyntaxError: Unexpected end of JSON input instead of actually proxying to R2, which is what made this look broken in the first place.
  • Document in scripts/README.md (new "Previewing images locally" section, right after "Publishing an image") 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.
  • Add .wrangler to .gitignore (the local state directory wrangler dev creates), matching the equivalent fix in magistrala-docs.

This is a follow-up to the equivalent fix already merged in magistrala-docs: absmach/magistrala-docs#171

Context

After publishing an image to R2 for this site, there was no way to preview it locally: next dev has no concept of the image-proxy Worker (worker/index.ts), and wrangler dev's R2 binding defaulted to an empty local simulator rather than the real bucket. On top of that, the wrangler version this repo had pinned (4.115.0) hits a real bug where a remote R2 binding throws instead of proxying — confirmed fixed at 4.120.0.

Test plan

  • pnpm run build && npx wrangler dev — startup banner shows env.IMAGES_BUCKET (websites-images) R2 Bucket remote (mode = remote, not local)
  • Homepage (/) returns 200 (redirects to /docs/propeller/architecture/, which itself returns 200)
  • Hit real, already-published doc image paths referenced from this repo's .mdx content (e.g. /docs/propeller/img/dag/basic-dag.svg, /docs/propeller/img/wasi-nn/proplet.svg, /docs/propeller/img/dag/architecture.svg) through the running wrangler dev — all returned 200 with correct Content-Type: image/svg+xml
  • Confirmed remote is local-dev-only per the installed wrangler's own config-schema.json — no effect on the deployed Worker
  • ./node_modules/.bin/wrangler --version reports 4.120.0 after pnpm install

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.115.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 command -- this repo deploys via plain `wrangler deploy`
(Workers + static assets), not Pages, so `pages dev` silently drops the R2
binding entirely.

Also gitignore .wrangler/, the local state directory `wrangler dev` creates,
matching the equivalent fix in magistrala-docs.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 7, 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 Updated (UTC)
❌ Deployment failed
View logs
propeller-docs de1d598 Aug 07 2026, 04:46 PM

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.

1 participant