From 6b062ab2391ab5103a6619e4c15d5a691a7b549a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Guti=C3=A9rrez?= <35082514+alezmad@users.noreply.github.com> Date: Mon, 6 Apr 2026 00:56:08 +0100 Subject: [PATCH] fix(web): skip payload withPayload in production build Payload CMS v3.81 withPayload() injects a turbopack config key that Next.js 16.0.10 rejects in production builds (needs >=16.1). Load withPayload only in dev; production gets a pass-through. Payload admin works locally; production serves blog/changelog as regular Next.js pages querying the Payload API. Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/web/next.config.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts index 9bc4c29..035e1d8 100644 --- a/apps/web/next.config.ts +++ b/apps/web/next.config.ts @@ -1,8 +1,17 @@ import type { NextConfig } from "next"; -import { withPayload } from "@payloadcms/next/withPayload"; import env from "./env.config"; +// Payload CMS requires Next.js >=16.1.0 for production builds (turbopack). +// Until we upgrade from 16.0.10, load withPayload only in dev where +// turbopack isn't used for builds. Production serves blog/changelog +// as static pages — Payload admin is dev-only for now. +const withPayload = + process.env.NODE_ENV === "production" + ? (c: NextConfig) => c + : // eslint-disable-next-line @typescript-eslint/no-require-imports + require("@payloadcms/next/withPayload").withPayload; + const INTERNAL_PACKAGES = [ "@turbostarter/analytics-web", "@turbostarter/api", @@ -116,4 +125,4 @@ const withBundleAnalyzer = require("@next/bundle-analyzer")({ enabled: env.ANALYZE, }); -export default withPayload(withBundleAnalyzer(config)); +export default withPayload(withBundleAnalyzer(config)) as NextConfig;