GenerateStaticParams + DynamicParams=false not Working in Next13

I am using generateStaticParams:
export async function generateStaticParams() {
let blogPosts = await prisma.posts.findMany({
where: {
category: "POLITICS",
},
});

const paths = blogPosts.map((text) => ({
slug: text.slug,
}));


return paths
}
export async function generateStaticParams() {
let blogPosts = await prisma.posts.findMany({
where: {
category: "POLITICS",
},
});

const paths = blogPosts.map((text) => ({
slug: text.slug,
}));


return paths
}
I want to only generate static pages for this route, and return a 404 when a user tries to visit something that does not exist at build time. So I am opting out of dynamic like so:
export default MyPage;
export const dynamic = 'force-static'
export const dynamicParams = false;
export default MyPage;
export const dynamic = 'force-static'
export const dynamicParams = false;
However, when I build this, this gives me a 404 for all my static routes. It works when I leave things dynamic and also in development, but not when I build the project. Next.JS also tells me that it recgonised the page and generated a static version, so it looks like it DID work:
├ ● /posts/[slug] 0 B 0 B
├ └ /posts/my-static-post
├ ○ /about 0 B 0 B
├ ● /posts/[slug] 0 B 0 B
├ └ /posts/my-static-post
├ ○ /about 0 B 0 B
However: when I visit it in production, it return a 404. Am I misunderstanding how this is supposed to be used?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server