Skip to content

TRAC-2749: feat - Serve local theme assets from the local renderer in Makeswift preview - #1428

Open
parthshahp wants to merge 3 commits into
masterfrom
parthshah/ltrac-3048-stencil-cli-1012-breaks-cdn-referenced
Open

parthshahp wants to merge 3 commits into
masterfrom
parthshah/ltrac-3048-stencil-cli-1012-breaks-cdn-referenced

Conversation

@parthshahp

@parthshahp parthshahp commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What?

In Makeswift preview mode, stencil start returns 404 for local theme images such as {{cdn "assets/img/coming-soon.jpg"}}. Version 9.1.0 serves them.

The cause is Cloudflare's legacy-origin bypass routes. The preview front door sends every request to the storefront, so /stencil/<version>/img/coming-soon.jpg skips the Makeswift worker and the tunnel. The live origin answers it and returns 404, because the local version ID does not exist there. JS and CSS still load because dist/ and css/ are not bypass routes.

  • createPreviewProxy sends the renderer's file routes (/stencil/*, /assets/*, and /favicon.ico) to the local renderer with x-stencil-preview-secret. These routes come from server/plugins/router/router.module.js.
  • All other requests still go to the storefront with the HMAC proof, as before. The loopback Host check, the Origin check, and the path normalization still run for every request.
  • MakeswiftPreview keeps the renderer port from start() and passes it to the proxy.

I tested this against a Makeswift-enabled production store running Cornerstone. Before the fix, /stencil/<v>/img/coming-soon.jpg returned 404 from the live origin. After the fix, it returns 200 with the local file's bytes. The 5 local asset URLs on the home page load, and the home page still goes through the Makeswift worker.

Tickets / Documentation

cc @bigcommerce/storefront-team

@parthshahp
parthshahp force-pushed the parthshah/ltrac-3048-stencil-cli-1012-breaks-cdn-referenced branch from 6986b6d to 4fbffef Compare November 20, 2026 15:59
… Makeswift preview

Cloudflare's legacy-origin bypass routes, such as */img/* and */assets/*, match anywhere in the path. Theme asset paths such as /stencil/<version>/img/... skipped the Makeswift worker and returned 404 from the live origin.

In Makeswift preview, the local front door now sends the renderer's file routes (/stencil/*, /assets/*, and /favicon.ico) to the local renderer with the session secret. All other requests still go to the storefront, signed as before.
@parthshahp
parthshahp force-pushed the parthshah/ltrac-3048-stencil-cli-1012-breaks-cdn-referenced branch from 4fbffef to 680eade Compare November 20, 2026 16:00
@parthshahp parthshahp changed the title TRAC-2749: fix - Serve local theme assets from the local renderer in Makeswift preview TRAC-2749: feat - Serve local theme assets from the local renderer in Makeswift preview Nov 20, 2026
@parthshahp
parthshahp marked this pull request as ready for review November 20, 2026 16:00
Comment thread lib/preview-proxy.js Resolved
…l renderer

The renderer's file routes are GET routes, and hapi also answers HEAD for them. Other methods on those paths reach the renderer's catch-all route, so they now go to the storefront, signed, like every other request.
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.

3 participants