From 817df12ad37bff2ff95e394529adc6f690f2e0c6 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 21:11:53 +0000 Subject: [PATCH] Let Server Actions through the live preview in `next dev` 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 Claude-Session: https://claude.ai/code/session_019PcpNV6SjymJBPv3nNkC4z --- apps/web/next.config.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts index f325f26..8545cb5 100644 --- a/apps/web/next.config.ts +++ b/apps/web/next.config.ts @@ -75,6 +75,16 @@ export default function nextConfig(phase: string): NextConfig { // 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: { + // 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"] } } + : {}), + }, // Only a production build reads the wrangler config: `next dev` keeps the // template's own behaviour — `.env.local`, or its "connect Supabase" // steps when there is none.