From 2be08ab85fa02741d6291c638a34921ca098c88f 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 09:16:38 +0100 Subject: [PATCH] fix(web): withPayload + redirect admin + externalized packages Final working pattern: withPayload via require() for build compatibility, admin page replaced with redirect (no RootPage import = no React #130), payload packages externalized from turbopack bundle. Blog/changelog use server-side getPayload(). Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/web/next.config.ts | 5 ++++- apps/web/src/app/(payload)/layout.tsx | 14 ++++++++++++++ .../app/(payload)/payload/[[...segments]]/page.tsx | 7 +++++++ apps/web/src/app/(payload)/payload/importMap.js | 1 + 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 apps/web/src/app/(payload)/layout.tsx create mode 100644 apps/web/src/app/(payload)/payload/[[...segments]]/page.tsx create mode 100644 apps/web/src/app/(payload)/payload/importMap.js diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts index 63e05c2..a1c12e4 100644 --- a/apps/web/next.config.ts +++ b/apps/web/next.config.ts @@ -1,5 +1,8 @@ import type { NextConfig } from "next"; +// eslint-disable-next-line @typescript-eslint/no-require-imports +const { withPayload } = require("@payloadcms/next/withPayload"); + import env from "./env.config"; const INTERNAL_PACKAGES = [ @@ -121,4 +124,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)/layout.tsx b/apps/web/src/app/(payload)/layout.tsx new file mode 100644 index 0000000..bdcfe53 --- /dev/null +++ b/apps/web/src/app/(payload)/layout.tsx @@ -0,0 +1,14 @@ +import "@payloadcms/next/css"; +import type { ReactNode } from "react"; + +export const metadata = { + title: "CMS — claudemesh", +}; + +export default function PayloadLayout({ children }: { children: ReactNode }) { + return ( + + {children} + + ); +} diff --git a/apps/web/src/app/(payload)/payload/[[...segments]]/page.tsx b/apps/web/src/app/(payload)/payload/[[...segments]]/page.tsx new file mode 100644 index 0000000..fb963c6 --- /dev/null +++ b/apps/web/src/app/(payload)/payload/[[...segments]]/page.tsx @@ -0,0 +1,7 @@ +import { redirect } from "next/navigation"; + +// Payload admin disabled in production standalone output. +// Use local dev server for CMS admin. +export default function PayloadAdminRedirect() { + redirect("/"); +} diff --git a/apps/web/src/app/(payload)/payload/importMap.js b/apps/web/src/app/(payload)/payload/importMap.js new file mode 100644 index 0000000..73849ab --- /dev/null +++ b/apps/web/src/app/(payload)/payload/importMap.js @@ -0,0 +1 @@ +export const importMap = {};