From 78c80cc43cb92b86abee4d20e9b0f0d25999ef14 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 02:26:13 +0100 Subject: [PATCH] fix(web): withPayload for build, admin redirects to home Keep withPayload (needed for build compilation) but replace the admin RootPage with a redirect. The RootPage's ConfigProvider causes React #130 in standalone output. Blog/changelog use server-side getPayload() which works fine. Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/web/next.config.ts | 11 ++++------- .../(payload)/payload/[[...segments]]/page.tsx | 18 ++++++------------ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts index b29b580..66fac57 100644 --- a/apps/web/next.config.ts +++ b/apps/web/next.config.ts @@ -1,12 +1,9 @@ import type { NextConfig } from "next"; -import env from "./env.config"; +// eslint-disable-next-line @typescript-eslint/no-require-imports +const { withPayload } = require("@payloadcms/next/withPayload"); -// withPayload is disabled until Payload admin runs correctly in -// Next.js standalone output. The wrapper injects a client-side -// provider that crashes with React #130 on all routes when the -// admin panel can't initialize. Blog + changelog use Payload's -// local API (server-side getPayload()) which works without the wrapper. +import env from "./env.config"; const INTERNAL_PACKAGES = [ "@turbostarter/analytics-web", @@ -121,4 +118,4 @@ const withBundleAnalyzer = require("@next/bundle-analyzer")({ enabled: env.ANALYZE, }); -export default withBundleAnalyzer(config); +export default withPayload(withBundleAnalyzer(config)); diff --git a/apps/web/src/app/(payload)/payload/[[...segments]]/page.tsx b/apps/web/src/app/(payload)/payload/[[...segments]]/page.tsx index d72f5cd..2b49cdd 100644 --- a/apps/web/src/app/(payload)/payload/[[...segments]]/page.tsx +++ b/apps/web/src/app/(payload)/payload/[[...segments]]/page.tsx @@ -1,14 +1,8 @@ -/* eslint-disable */ -// @ts-nocheck — Payload generates these types at build time -import { RootPage, generatePageMetadata } from "@payloadcms/next/views"; -import { importMap } from "../importMap"; -import config from "@payload-config"; +import { redirect } from "next/navigation"; -type Args = { params: Promise<{ segments: string[] }> }; - -export const generateMetadata = ({ params }: Args) => - generatePageMetadata({ config, params }); - -export default function Page({ params }: Args) { - return ; +// Payload admin panel disabled in production (standalone output +// doesn't support Payload's server init). Content managed via +// local dev server or API. +export default function PayloadAdminRedirect() { + redirect("/"); }