From d1ce3bda5c58fc6a1af081321a18f58586adb82e Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 21:25:45 +0000 Subject: [PATCH 1/2] Declare the site's live preview (saas-parallel-baselining PB4) 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..."), builds packages/client (the workspace package whose dist/ the site loads), writes the GraphQL types from the committed schema (scripts/generate.cjs, as `pnpm dev` does), then runs `next dev` alone on localhost:3000 with a 1 GiB heap cap; the tab opens /. --dns-result-order=ipv4first makes localhost 127.0.0.1 alone, and `localhost` keeps the proxy's rewrites in-process behind the gateway (Next normalizes 127.0.0.1 to localhost in a request's URL, and with -H 127.0.0.1 every rewrite looked external: a 500 under x-forwarded-proto: https). On a Node without the URLPattern global (it is Node 24's) `next dev` preloads the site's own urlpattern-polyfill, which the proxies' matchers need. It is given no BigCommerce store. - intent.yaml: preview: {component: web}. - apps/web/next.config.ts: allowedDevOrigins for the preview's hosts (*.orun-preview.app, preview-gateway-stage.oruncloud.workers.dev), and, only when NODE_ENV is development, experimental.serverActions .allowedOrigins for the same hosts. The gateway passes the browser's Origin through while `next dev` sees a local Host: Next 16 refuses the hot reload's WebSocket and every Server Action from an origin it is not told about. `next build` reads neither. - apps/web/lib/content-security-policy.ts: `next dev` sends no frame-ancestors (NODE_ENV=development only). The storefront's `frame-ancestors 'none'` kept the dev server out of the Preview tab's frame, and the gateway can only add to it. `next build` runs with NODE_ENV=production, so the deployed storefront's CSP is unchanged. - baseline.yml: orun v2.88.0 -> v2.96.0 (all three jobs), the first release that reads spec.preview, so the placement's `orun validate` checks it. ci.yml (the site's own lane pin) is unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_019PcpNV6SjymJBPv3nNkC4z --- .github/workflows/baseline.yml | 18 ++++++++------ apps/web/component.yaml | 31 +++++++++++++++++++++++++ apps/web/lib/content-security-policy.ts | 8 ++++++- apps/web/next.config.ts | 17 ++++++++++++++ intent.yaml | 7 ++++++ 5 files changed, 73 insertions(+), 8 deletions(-) diff --git a/.github/workflows/baseline.yml b/.github/workflows/baseline.yml index 08354df..0c58662 100644 --- a/.github/workflows/baseline.yml +++ b/.github/workflows/baseline.yml @@ -60,8 +60,11 @@ jobs: # Tier 1. THE BLUEPRINT, READ AND PLACED BY THE BINARY A BOOTSTRAP RUNS. # - # Pinned at the bootstrap floor (BOOTSTRAP.md), not the site's lane pin: - # every test here reads YAML with PyYAML, which parses anything well-formed; + # Pinned at v2.96.0, not the site's lane pin: at or above the bootstrap + # floor (v2.88.0, BOOTSTRAP.md), and the first orun that reads a + # component's `spec.preview`, so the placement's `orun validate` checks the + # site's live preview too. Every test here reads YAML with PyYAML, which + # parses anything well-formed; # only the pinned orun can say whether the document is one a bootstrap can # run. `--status` parses it, validates every hook against the action # registry, compiles every `when` and narration template, and writes @@ -76,7 +79,7 @@ jobs: - uses: actions/checkout@v6 - uses: sourceplane/orun-action@v1.2.0 with: - version: v2.88.0 + version: v2.96.0 - uses: pnpm/action-setup@v4 with: version: 10.12.1 @@ -115,7 +118,7 @@ jobs: # runs the floor, which is newer than the lane pin. - uses: sourceplane/orun-action@v1.2.0 with: - version: v2.88.0 + version: v2.96.0 - name: placement — the offline bootstrap, and the product's own plan run: | git config --global user.email ci@example.invalid @@ -126,8 +129,9 @@ jobs: # fixture rendered, type-checked, linted, tested and built, the stage lane's # own structure check, build (the live wiring render included), output check # and dry deploy in the tree orun stages, and the built Worker served and - # smoke-tested with the component's own smoke command. Pinned at the - # bootstrap floor (v2.88.0): the offline bootstrap reads the blueprint, and + # smoke-tested with the component's own smoke command. Pinned at + # v2.96.0, above the bootstrap floor (v2.88.0), the first orun that + # reads `spec.preview`: the offline bootstrap reads the blueprint, and # the floor is newer than the product's lane pin (v2.78.4), which is all the # lane steps need. site: @@ -136,7 +140,7 @@ jobs: - uses: actions/checkout@v6 - uses: sourceplane/orun-action@v1.2.0 with: - version: v2.88.0 + version: v2.96.0 - uses: pnpm/action-setup@v4 with: version: 10.12.1 diff --git a/apps/web/component.yaml b/apps/web/component.yaml index 0ec9bb5..ed29298 100644 --- a/apps/web/component.yaml +++ b/apps/web/component.yaml @@ -82,6 +82,37 @@ spec: - profile: deploy when: triggerRef: github-push-main + # How the site runs itself for orun.work's live Preview tab + # (saas-parallel-baselining PB4): `orun preview` starts this, and a coding + # session keeps it running while it works, so the person watches it change + # as it is built. The dev server binds the box's loopback only, on a fixed + # port, and installs first, so a checkout the session has not installed yet + # still comes up. + # Before it starts, it builds the one workspace package the site imports + # (packages/client, whose dist/ `next dev` loads) and writes the GraphQL + # types from the committed schema (scripts/generate.cjs, as `pnpm dev` + # does; offline). The proxies build their matchers with URLPattern, a + # global from Node 24 on: on an older Node `next dev` preloads the site's + # own urlpattern-polyfill (a devDependency, the one its tests load), which + # fills it in only where it is missing. It binds `localhost`, which + # --dns-result-order=ipv4first resolves to 127.0.0.1 alone: the proxy's + # rewrites (/ to the connect page, the locale and channel routes) stay + # in-process only when the dev server's own URL says localhost, as Next + # normalizes 127.0.0.1 in a request's URL to localhost and would proxy a + # rewrite to a host it took for another one. With no BigCommerce store + # connected (the preview is given none of its secrets), / is the + # storefront's "connect your store" page and every other page redirects + # there, as a fresh deploy's do. + preview: + run: + - sh + - -c + - pnpm install --frozen-lockfile --prefer-offline --filter "@app/web..." && (cd ../../packages/client && exec node_modules/.bin/tsup) && node scripts/generate.cjs && exec env NODE_OPTIONS="$NODE_OPTIONS --import urlpattern-polyfill" node_modules/.bin/next dev -H localhost -p 3000 + port: 3000 + path: / + env: + NODE_OPTIONS: --max-old-space-size=1024 --dns-result-order=ipv4first + NEXT_TELEMETRY_DISABLED: "1" parameters: nodeVersion: "22" pnpmVersion: "10.12.1" diff --git a/apps/web/lib/content-security-policy.ts b/apps/web/lib/content-security-policy.ts index c6259b4..248d563 100644 --- a/apps/web/lib/content-security-policy.ts +++ b/apps/web/lib/content-security-policy.ts @@ -6,11 +6,17 @@ const makeswiftBaseUrl = process.env.MAKESWIFT_BASE_URL || 'https://app.makeswif const frameAncestors = makeswiftEnabled ? makeswiftBaseUrl : 'none'; +// Dev server only: `next dev` sends no frame-ancestors, because orun.work's +// live Preview tab shows the dev server in a frame and its gateway can only +// add to a page's frame-ancestors, never loosen them. `next build` runs with +// NODE_ENV=production, so the deployed storefront keeps the directive. +const framing = process.env.NODE_ENV === 'development' ? {} : { frameAncestors: [frameAncestors] }; + // customize the directives as needed export const cspHeader = builder({ directives: { baseUri: ['self'], - frameAncestors: [frameAncestors], + ...framing, // formAction: ['self'], // defaultSrc: ['self'], // scriptSrc: ['self'], diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts index 6b544e8..807de96 100644 --- a/apps/web/next.config.ts +++ b/apps/web/next.config.ts @@ -76,8 +76,25 @@ export default async (): Promise => { '../../node_modules/.pnpm/@opentelemetry+api@*/node_modules/@opentelemetry/api/build/**', ], }, + // Dev server only (`next build` ignores it): orun.work's live Preview tab + // loads `next dev` from the preview's own host, and Next.js refuses the + // hot reload and other /_next/* dev requests from an origin it is not told + // about. These are the preview's hosts, prod's and stage's. + allowedDevOrigins: ['*.orun-preview.app', 'preview-gateway-stage.oruncloud.workers.dev'], experimental: { optimizePackageImports: ['@icons-pack/react-simple-icons'], + // Dev server only: behind orun.work's live Preview the browser's Origin + // is the preview's host while `next dev` sees a local Host, and Next.js + // refuses a Server Action from an origin it is not told about. `next + // build` runs with NODE_ENV=production, so production keeps its + // same-origin check. + ...(process.env.NODE_ENV === 'development' + ? { + serverActions: { + allowedOrigins: ['*.orun-preview.app', 'preview-gateway-stage.oruncloud.workers.dev'], + }, + } + : {}), }, images: { // Allow product-video poster thumbnails (YouTube) through next/image. diff --git a/intent.yaml b/intent.yaml index 5a81065..b25d95a 100644 --- a/intent.yaml +++ b/intent.yaml @@ -57,6 +57,13 @@ compositions: cloudflare-domain: stack-tectonic db-migrate: stack-tectonic +# The live preview (saas-parallel-baselining PB4): the component orun.work's +# Preview tab shows while a coding session works on the site. Its own +# `spec.preview` (apps/web/component.yaml) says how it runs; `orun preview` +# runs it. +preview: + component: web + discovery: roots: - apps/ From cc49a760804490e11d97525edfb2bb363e095cc3 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 21:30:26 +0000 Subject: [PATCH 2/2] Type the dev-only CSP directives so the type check passes `framing` was inferred as `{} | { frameAncestors: string[] }`, which TypeScript widens to an optional `frameAncestors?: undefined` that content-security-policy-builder's directive map refuses (TS2322 in the site job's typecheck). Annotating it as Record keeps the same value: no frame-ancestors under `next dev`, the same header for every build. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_019PcpNV6SjymJBPv3nNkC4z --- apps/web/lib/content-security-policy.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/web/lib/content-security-policy.ts b/apps/web/lib/content-security-policy.ts index 248d563..5680675 100644 --- a/apps/web/lib/content-security-policy.ts +++ b/apps/web/lib/content-security-policy.ts @@ -10,7 +10,8 @@ const frameAncestors = makeswiftEnabled ? makeswiftBaseUrl : 'none'; // live Preview tab shows the dev server in a frame and its gateway can only // add to a page's frame-ancestors, never loosen them. `next build` runs with // NODE_ENV=production, so the deployed storefront keeps the directive. -const framing = process.env.NODE_ENV === 'development' ? {} : { frameAncestors: [frameAncestors] }; +const framing: Record = + process.env.NODE_ENV === 'development' ? {} : { frameAncestors: [frameAncestors] }; // customize the directives as needed export const cspHeader = builder({