Skip to content

Make published R2 images visible in local dev - #72

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

Make published R2 images visible in local dev#72
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.81.1 -> ^4.120.0 (and update pnpm-lock.yaml/pnpm-workspace.yaml accordingly): 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, 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.

Context

This is a follow-up to the equivalent fix already merged in the sibling magistrala-docs repo: absmach/magistrala-docs#171. Same root cause here: after publishing an image to R2, there was no way to preview it locally — next dev has no concept of the image-proxy Worker, and wrangler pages dev (the wrong command for this project) either serves an empty local R2 simulator or drops the binding outright.

Test plan

  • pnpm run build — succeeds, produces ./out
  • npx wrangler dev — startup binding table shows env.IMAGES_BUCKET (websites-images) R2 Bucket remote (mode = remote, not local)
  • Homepage (/) returns 200 (redirects 301 -> /docs/cube-ai/, which is existing basePath behavior, then 200)
  • Hit several already-published doc image URLs through the running wrangler dev (/docs/cube-ai/img/ui/domains.png, /docs/cube-ai/img/ui/chat.png, /docs/cube-ai/img/vllm-architecture.png, /docs/cube-ai/img/ui/login.png) — all returned 200, no SyntaxError crash
  • ./node_modules/.bin/wrangler --version reports 4.120.0

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.81.1 -> ^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.
@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 Preview URL Updated (UTC)
🔵 In progress
View logs
cube-docs 6647868 Commit Preview URL

Branch Preview URL
Aug 07 2026, 04:49 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