Skip to content

Preview the storefront from / on a localhost-bound next dev (saas-parallel-baselining PB4) - #6

Merged
ruehowl merged 1 commit into
mainfrom
claude/preview-localhost
Nov 4, 2026
Merged

ruehowl merged 1 commit into
mainfrom
claude/preview-localhost

Conversation

@ruehowl

@ruehowl ruehowl commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

What

Follow-up to #5. The storefront's live preview now opens /, its home, instead of /dk.

  • apps/web/component.yaml: spec.preview runs next dev -H localhost -p 8000 (was -H 127.0.0.1), adds --dns-result-order=ipv4first to NODE_OPTIONS, and sets path: /:
    preview:
      run:
      - sh
      - -c
      - pnpm install --frozen-lockfile --prefer-offline --filter "@app/web..." && exec node_modules/.bin/next dev -H localhost -p 8000
      port: 8000
      path: /
      env:
        NODE_OPTIONS: --max-old-space-size=1024 --dns-result-order=ipv4first
        NEXT_TELEMETRY_DISABLED: '1'

Nothing about how the storefront builds or deploys changes.

Why

The middleware rewrites / to the default region (NextResponse.rewrite(new URL("/dk", request.url))). Under next dev -H 127.0.0.1, Next hands the middleware a localhost URL while its own origin is 127.0.0.1, so it treats every rewrite as external and proxies it to itself. Behind the gateway, which passes x-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. Binding localhost makes the two origins agree, so the rewrite stays internal. --dns-result-order=ipv4first keeps localhost on 127.0.0.1 on a box whose resolver lists ::1 first. 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:

Check Result
orun validate passes
orun preview start --json ready in 9.2 s
GET / 200, 76.0 KB, "Medusa Store"; with x-forwarded-proto: https: 200, no "Failed to proxy"
listener tcp4 0100007F:1F40 (127.0.0.1:8000) only; [::1]:8000 refuses
through the gateway stand-in, framed frame 200, no failed assets, no console errors, hot-reload socket connected
an edit reaches the frame hot update in 0.5s
memory dev server 1265 MB at its peak
orun preview stop stops it; port freed

That 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 absolute http://127.0.0.1:8000/… built from the local Host, which leaves the preview. In-app links carry the country code.


Generated by Claude Code

…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
ruehowl marked this pull request as ready for review November 4, 2026 21:24
@ruehowl
ruehowl merged commit 4c35150 into main Nov 4, 2026
5 checks passed
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.

2 participants