Repository navigation
Preview the storefront from / on a localhost-bound next dev (saas-parallel-baselining PB4) - #6
Merged
Merged
Conversation
…allel-baselining PB4) The live preview (#5) opened /dk because `/` failed behind orun.work's preview gateway. The middleware rewrites `/` to the default region, and under `next dev -H 127.0.0.1` Next gives the middleware a `localhost` URL, treats the rewrite as external and proxies it to itself, over TLS once the gateway's `x-forwarded-proto: https` arrives ("Failed to proxy … EPROTO"). - apps/web/component.yaml: spec.preview runs `next dev -H localhost -p 8000`, with `--dns-result-order=ipv4first` in NODE_OPTIONS so `localhost` stays on 127.0.0.1 (it listens on tcp4 127.0.0.1:8000 only; [::1]:8000 refuses), and the tab opens / again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019PcpNV6SjymJBPv3nNkC4z
ruehowl
marked this pull request as ready for review
November 4, 2026 21:24
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.
What
Follow-up to #5. The storefront's live preview now opens
/, its home, instead of/dk.apps/web/component.yaml:spec.previewrunsnext dev -H localhost -p 8000(was-H 127.0.0.1), adds--dns-result-order=ipv4firsttoNODE_OPTIONS, and setspath: /:Nothing about how the storefront builds or deploys changes.
Why
The middleware rewrites
/to the default region (NextResponse.rewrite(new URL("/dk", request.url))). Undernext dev -H 127.0.0.1, Next hands the middleware alocalhostURL while its own origin is127.0.0.1, so it treats every rewrite as external and proxies it to itself. Behind the gateway, which passesx-forwarded-proto: https, that proxy goes over TLS to a plain-http server and fails:Failed to proxy https://localhost:8000/dk … EPROTO wrong version number,/500. Bindinglocalhostmakes the two origins agree, so the rewrite stays internal.--dns-result-order=ipv4firstkeepslocalhoston 127.0.0.1 on a box whose resolver lists::1first. This is the fleet recipe for Next apps whose middleware rewrites (proven first on next-forge#6).Checked
From a clean clone, with orun v2.96.0, through the local gateway stand-in, framed from a foreign origin:
orun validateorun preview start --jsonreadyin 9.2 sGET /x-forwarded-proto: https: 200, no "Failed to proxy"0100007F:1F40(127.0.0.1:8000) only;[::1]:8000refusesorun preview stopThat run had the one harness-only Server Actions origin (
abc123def456.orun-preview.app:18000) that #5 also used, so the on-load Server Action ran. It is not in this PR.Still out of reach
A URL without a country code (
/store) is redirected by the middleware to${request.nextUrl.origin}/dk/store, an absolutehttp://127.0.0.1:8000/…built from the localHost, which leaves the preview. In-app links carry the country code.Generated by Claude Code