Skip to content

Let Server Actions through the live preview in next dev - #14

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

ruehowl merged 1 commit into
mainfrom
claude/preview-server-actions

Conversation

@ruehowl

@ruehowl ruehowl commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

What

A follow-up to #13 (baseline-v7, the site's live preview), from the same rollout (saas-parallel-baselining PB4).

Behind orun.work's live Preview, the browser's Origin is the preview's host while next dev sees Host: 127.0.0.1:3000, and Next refuses a Server Action from an origin that is not the Host ("Invalid Server Actions request", a 500 on the POST). allowedDevOrigins (#13) covers the hot reload and /_next/*, not Server Actions. Every Next baseline gets this allow-list, whether or not it has Server Actions today, so a session that adds a form does not break its preview.

  • apps/web/next.config.ts, inside experimental:
    ...(process.env.NODE_ENV === "development"
      ? { serverActions: { allowedOrigins: ["*.orun-preview.app", "preview-gateway-stage.oruncloud.workers.dev"] } }
      : {}),
    next build runs with NODE_ENV=production, so the deployed Worker keeps its same-origin check.

Nothing about how the site builds or deploys changes.

Checked

From a clean clone, with orun v2.96.0, through the local stand-in of the preview gateway:

Check Result
orun preview start --json ready in 9.6 s; next dev lists serverActions under its experiments
GET / 200, 55.3 KB, "Next.js Supabase Starter" (the "connect Supabase" steps, as in #13)
framed through the gateway stand-in frame 200, hot-reload socket connected, an edit to app/page.tsx hot-updated in 0.5 s
memory dev server ~1.2 GB, as in #13
orun preview stop stops it; port freed

The allow-list itself was checked against the running next dev of other Next 16.3 baselines that have Server Actions (sourceplane/subscription-payments, sourceplane/nl-postgres), POSTing an action with each Origin: https://abc123def456.orun-preview.app and the stage gateway host pass Next's origin check (404, action not found), https://elsewhere.example.com is refused (500, "Invalid Server Actions request"). This site has no Server Actions yet, so Next answers any action POST "not found" before that check.


Generated by Claude Code

Behind orun.work's live Preview the browser's Origin is the preview's host
while `next dev` sees Host 127.0.0.1:3000, and Next refuses a Server Action
from an origin that is not the Host ("Invalid Server Actions request").
allowedDevOrigins (baseline-v7) covers the hot reload, not this.

- apps/web/next.config.ts: inside `experimental`, the preview's hosts
  (*.orun-preview.app, preview-gateway-stage.oruncloud.workers.dev) as
  serverActions.allowedOrigins, only when NODE_ENV is development
  (`next dev`). `next build` runs with NODE_ENV=production, so the
  deployed Worker keeps its same-origin check.

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:14
@ruehowl
ruehowl merged commit 9c44ac4 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