works fine in dev, but when running a build everything is static (3.0 beta) #8596
-
I'm really struggling for a few days to understand what's the magic setting to make my builds reflect my work from dev mode and I can't seem to figure it out. For example's sake, this is a header which pulls data from a global with the slug 'header' : import { getPayloadHMR } from '@payloadcms/next/utilities'
import config from '@payload-config'
import { HeaderPayloadClient } from './headerPayloadClient' // this toggles dark/light so it has to be in it's own client component
import Link from 'next/link'
export default async function Header() {
const payload = await getPayloadHMR({ config })
const header = await payload.findGlobal({ slug: 'header' })
return (
<header className="fixed z-50 w-full bg-white shadow-md dark:bg-gray-800">
<div className="container mx-auto flex items-center justify-between px-4 py-4">
<h1 className="bg-gradient-to-r from-blue-500 to-purple-600 bg-clip-text text-4xl font-bold text-transparent">
{header.LogoText ?? <Link href="#top">{header.LogoText}</Link>}
</h1>
<div className="flex items-center space-x-8">
<nav className="hidden space-x-8 md:flex">
<ul>
{header.menuItems.map((menuItem) => {
return (
<Link href={menuItem.url} key={menuItem.id}>
{menuItem.label}
</Link>
)
})}
</ul>
<HeaderPayloadClient />
</nav>
</div>
</div>
</header>
)
} When I edit the global named "Header" in the /admin section of my site, everyhting updates just right both in the db, and on the front page. However, when I build this with bun run build and then bun run start, or alternatively add an output: "standalone" to next's config and then run the standalone build, only the databse updates, but the frontend doesn't show any changes. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @seccentral, When you build the next app it should tell you whether or not your pages are static, dynamic, etc. This honestly sounds like a cache or revalidating issue to me. I'd encourage you to take a look at the website templates Header global. Notice how they are revalidation after changes in a hook on the global configuration - chefs kiss of functionality. |
Beta Was this translation helpful? Give feedback.
Hey @seccentral,
When you build the next app it should tell you whether or not your pages are static, dynamic, etc.
This honestly sounds like a cache or revalidating issue to me. I'd encourage you to take a look at the website templates Header global.
Notice how they are revalidation after changes in a hook on the global configuration - chefs kiss of functionality.