Make published R2 images visible in local dev - #72
Open
ianmuchyri wants to merge 1 commit into
Open
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.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.
Deploying with
|
| 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 |
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
"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.wranglerdevDependency^4.81.1->^4.120.0(and updatepnpm-lock.yaml/pnpm-workspace.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", thatwrangler dev(notwrangler pages dev) is the correct local preview command — this repo deploys via plainwrangler deploy(Workers + static assets), not Pages, sopages devsilently drops the R2 binding entirely.Context
This is a follow-up to the equivalent fix already merged in the sibling
magistrala-docsrepo: absmach/magistrala-docs#171. Same root cause here: after publishing an image to R2, there was no way to preview it locally —next devhas no concept of the image-proxy Worker, andwrangler 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./outnpx wrangler dev— startup binding table showsenv.IMAGES_BUCKET (websites-images) R2 Bucket remote(mode = remote, not local)/) returns 200 (redirects 301 ->/docs/cube-ai/, which is existing basePath behavior, then 200)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, noSyntaxErrorcrash./node_modules/.bin/wrangler --versionreports4.120.0