Skip to content

Declare the storefront's live preview (saas-parallel-baselining PB4) - #5

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

ruehowl merged 1 commit into
mainfrom
claude/declare-preview

Conversation

@ruehowl

@ruehowl ruehowl commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

What

The baseline declares its live preview, so orun.work's Preview tab can show a coding session's dev server (saas-parallel-baselining PB4).

  • apps/web/component.yaml: spec.preview:
    preview:
      run:
      - sh
      - -c
      - pnpm install --frozen-lockfile --prefer-offline --filter "@app/web..." && exec node_modules/.bin/next dev -H 127.0.0.1 -p 8000
      port: 8000
      path: /dk
      env:
        NODE_OPTIONS: --max-old-space-size=1024
        NEXT_TELEMETRY_DISABLED: '1'
  • intent.yaml: preview: {component: web}.
  • apps/web/next.config.js: allowedDevOrigins: ["*.orun-preview.app", "preview-gateway-stage.oruncloud.workers.dev"]. The gateway gives the dev server a local Host but passes the browser's Origin through, and Next 16 refuses the hot reload's WebSocket from an unlisted origin (Unauthorized). Only next dev reads this setting; next build and the deployed Worker don't.
  • apps/web/next.config.js: experimental.serverActions.allowedOrigins for the same two hosts, under next dev only (process.env.NODE_ENV === "development" ? {…} : {}). Next refuses a Server Action whose Origin host is not the Host (Invalid Server Actions request, POST 500), and allowedDevOrigins does not cover it; a coding session that adds a form gets one. next build runs with NODE_ENV=production, so the deploy keeps its same-origin check.
  • .github/workflows/baseline.yml: orun v2.88.0 → v2.96.0, the first release that reads spec.preview, so the placement test's orun validate checks the declaration (its comments say so). ci.yml (the product's own lane pin, v2.78.4) is unchanged.

Nothing about how the baseline builds or deploys changes.

Checked

From a clean clone, with orun v2.96.0, and through a local stand-in of the preview gateway (the dev server sees a local Host and the browser's own Origin; the page is framed from a foreign origin):

Check Result
orun validate passes
orun preview start --json ready in 13.0 s (warm pnpm store)
GET /dk 200, 76.0 KB, "Medusa Store"
foreign Host + Origin straight to the dev server 200
through the gateway stand-in, framed frame 200, no failed assets, hot-reload socket connected
an edit reaches the frame hot update in 1.0s
memory dev server 1161 MB at its peak (page compiled, after an edit); the install peaks at 1210 MB
orun preview stop stops it; port freed

Notes

  • The tab opens /dk, not /. / is the middleware's rewrite (NextResponse.rewrite(new URL("/dk", request.url))), and behind the gateway it fails with "Failed to proxy https://localhost:8000/dk … EPROTO wrong version number". The gateway passes x-forwarded-proto: https through, and next dev then builds the middleware's URL with a different origin (https://localhost:8000) from its own (https://127.0.0.1:8000), so it treats the rewrite as external and proxies it to itself over TLS. Reproduced with curl: / answers 200 without the header and 500 with it. It needs no change here if the box stops forwarding x-forwarded-proto (raised with the platform owner).
  • 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, so browsing from /dk stays inside.
  • No Medusa backend is named (NEXT_PUBLIC_MEDUSA_BACKEND_URL and its publishable key are Orun secrets the build reads), so the preview runs on the storefront's sample catalogue, as a fresh product does. Port 8000 is the storefront's own next dev port.
  • The Server Action allow-list was proven in the run above with one extra, harness-only entry for the stand-in's origin (abc123def456.orun-preview.app:18000; the real preview origin has no port, which *.orun-preview.app matches). Without it the storefront's on-load Server Action is refused (Invalid Server Actions request, POST /dk 500); with it, no failed requests and no console errors. That entry is not in this PR.
  • Memory: the dev server peaks ~1.16–1.22 GB with /dk compiled (next-server ~1.0 GB), a little above the ~1 GiB aim. The first run was ready in 16.6 s.
  • Checked here: contract tests, gen-component-docs.py --check, placement.test.sh on v2.96.0.
  • Next 16.3's next dev writes apps/web/AGENTS.md and CLAUDE.md (its own agent rules) on startup, as it does for any next dev; this PR leaves that alone.

Generated by Claude Code

orun.work's Preview tab shows a coding session's dev server, live from its
box: `orun preview` (orun v2.96.0) runs what a repository declares, and the
session keeps it running while it works.

- apps/web/component.yaml: spec.preview. It installs this app's packages
  only (--filter "@app/web..."), then runs `next dev` alone on
  127.0.0.1:8000, with a 1 GiB heap cap; the tab opens /dk. Port 8000 is
  the storefront's own dev port (package.json). No Medusa backend is
  named, so it runs in sample mode. The tab opens /dk, the default
  region's home: `/` is the middleware's rewrite to it, which behind the
  preview `next dev` proxies to itself over https and fails.
- intent.yaml: preview: {component: web}.
- apps/web/next.config.js: allowedDevOrigins for the preview's hosts
  (*.orun-preview.app, preview-gateway-stage.oruncloud.workers.dev). The
  gateway passes the browser's Origin through, and Next 16 refuses the
  hot reload's WebSocket from an origin it is not told about. The
  setting is read by `next dev` only.
- apps/web/next.config.js: experimental.serverActions.allowedOrigins for
  the same hosts, under `next dev` only (NODE_ENV=development): Next
  refuses a Server Action whose Origin is not the Host. `next build`
  runs with NODE_ENV=production, so a deploy keeps its same-origin
  check.
- baseline.yml: orun v2.88.0 -> v2.96.0, the first release that reads
  spec.preview, so the placement's `orun validate` checks it. ci.yml
  (the product's own lane pin, v2.78.4) is unchanged.

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:01
@ruehowl
ruehowl merged commit 4724287 into main Nov 4, 2026
5 checks passed
ruehowl added a commit that referenced this pull request Nov 4, 2026
…allel-baselining PB4) (#6)

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.


Claude-Session: https://claude.ai/code/session_019PcpNV6SjymJBPv3nNkC4z

Co-authored-by: Claude <noreply@anthropic.com>
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