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) <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,9 @@
|
|||||||
import type { NextConfig } from "next";
|
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
|
import env from "./env.config";
|
||||||
// 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.
|
|
||||||
|
|
||||||
const INTERNAL_PACKAGES = [
|
const INTERNAL_PACKAGES = [
|
||||||
"@turbostarter/analytics-web",
|
"@turbostarter/analytics-web",
|
||||||
@@ -121,4 +118,4 @@ const withBundleAnalyzer = require("@next/bundle-analyzer")({
|
|||||||
enabled: env.ANALYZE,
|
enabled: env.ANALYZE,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withBundleAnalyzer(config);
|
export default withPayload(withBundleAnalyzer(config));
|
||||||
|
|||||||
@@ -1,14 +1,8 @@
|
|||||||
/* eslint-disable */
|
import { redirect } from "next/navigation";
|
||||||
// @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";
|
|
||||||
|
|
||||||
type Args = { params: Promise<{ segments: string[] }> };
|
// Payload admin panel disabled in production (standalone output
|
||||||
|
// doesn't support Payload's server init). Content managed via
|
||||||
export const generateMetadata = ({ params }: Args) =>
|
// local dev server or API.
|
||||||
generatePageMetadata({ config, params });
|
export default function PayloadAdminRedirect() {
|
||||||
|
redirect("/");
|
||||||
export default function Page({ params }: Args) {
|
|
||||||
return <RootPage config={config} params={params} importMap={importMap} />;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user