Enable remote R2 binding so local dev can preview published doc images - #62
Open
ianmuchyri wants to merge 1 commit into
Open
Enable remote R2 binding so local dev can preview published doc images#62ianmuchyri wants to merge 1 commit into
ianmuchyri wants to merge 1 commit into
Conversation
wrangler dev's R2 binding defaulted to an empty local simulator, so images already published to the shared websites-images bucket via publish-image.mjs were invisible in local dev (next dev has no knowledge of wrangler.jsonc at all and always 404s on doc images, which is separately expected). - Add "remote": true to the IMAGES_BUCKET binding in wrangler.jsonc. Local-dev-only setting per wrangler's own config-schema.json; no effect on the deployed Worker. - Bump wrangler from ^4.95.0 to ^4.120.0. Versions in that range have a bug where a remote R2 binding throws "SyntaxError: Unexpected end of JSON input" instead of proxying to R2; confirmed fixed at 4.120.0. - Document the workflow in scripts/README.md under a new "Previewing images locally" section. Follow-up to the equivalent fix in magistrala-docs: absmach/magistrala-docs#171
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
atom-docs | f5953b0 | Commit Preview URL Branch Preview URL |
Aug 07 2026, 04:56 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
Follow-up to the equivalent fix already shipped in magistrala-docs: absmach/magistrala-docs#171. Scoped entirely to
docs/— does not touch the Go service.After publishing a doc image via
publish-image.mjs, there was no way to preview it locally:pnpm run dev(plainnext dev) has no knowledge ofwrangler.jsonc/the Worker, so it always 404s on doc images (expected, unchanged by this PR).wrangler devruns the real Worker, but its R2 binding defaulted to an empty local simulated bucket, not the realwebsites-imagesbucket, so published images still 404'd.wranglerversion previously pinned (^4.95.0) also has a bug where a remote R2 binding throwsSyntaxError: Unexpected end of JSON inputinstead of proxying to R2 at all — confirmed fixed at 4.120.0.Three changes:
docs/wrangler.jsonc— add"remote": trueto theIMAGES_BUCKETr2_buckets binding. This is a local-dev-only setting (per wrangler's ownconfig-schema.json); has no effect on the deployed Worker, since bindings are always real there.docs/package.json— bump thewranglerdevDependency from^4.95.0to^4.120.0(lockfile updated viapnpm install).docs/scripts/README.md— new "Previewing images locally" section (right after "Publishing an image", before "Local development"), explaining thepnpm run previewworkflow. Also trimmed the now-stale/contradictory paragraph in the existing "Local development" section that told readers to add"remote": truetemporarily — it's now on by default, so that section points to the new one instead.Test plan
pnpm run buildsucceedswrangler devstartup banner showsenv.IMAGES_BUCKET (websites-images) R2 Bucket remote— mode isremote, notlocal, and noSyntaxErrorcrash/) 301s to/docs/atom/, which returns 200content/docs/**/*.mdxthrough the runningwrangler dev— all returned 200 with correctimage/pngcontent-type and byte sizes matching the originals removed from git in docs: serve doc images from R2 instead of committing them to git #57 (e.g.groups-list-populated.pngat exactly 112280 bytes)pnpm run typecheck:workerpasses (used by thedeploy/uploadscripts, confirms thewrangler.jsoncedit didn't break worker typechecking)./node_modules/.bin/wrangler --versionreports4.120.0