#nextjs 14 app in production throws 500:internal server error instead of 404 not found page

27 messages · Page 1 of 1 (latest)

hard mountain
#

hello , nextjs 14 app with next-intl ->
(main)/[locale]/projects/[projectsSlugName]/page.tsx
(the relevant parts of the page are below),

export async function generateStaticParams() {
  const projects = await getAllProjects();
  if (!projects) {
  return []
  }
  return projects.map((project)=>{
    return {projectSlugName:project.urlPath}
  })
}


const Page = async ({ params }: { params: { projectSlugName: string,locale: string  } }) => {
  unstable_setRequestLocale(params.locale)
  console.log("projectSlugName rendered ",params.projectSlugName)
  const t = await getTranslations("Constants");
  const Project = await getProjectWithLang(params.projectSlugName, params.locale);
  if (!Project) {
    notFound()
  }

When I use generateStaticParams in that route , when page return notFound() in npm run dev mode it shows 404 page , while in production it shows the page as 500:internal server error.

error message below :

Page changed from static to dynamic at runtime /tr/projects/doc-coffee-co-kafe-tasarimia, reason: headers

if i remove the generateStaticParams page returns 404 in both dev mode and production mode as it should be.

hollow kiteBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

topaz warren
#

can you show me this func? getAllProjects ?

#

and from your error message I think 500 error code is correct not 404

hard mountain
# topaz warren can you show me this func? `getAllProjects` ?
 export async function getAllProjects() {
    try {
      const allProjects = await prisma.project.findMany({
       orderBy:{index:"asc"},
       include:{medias:{orderBy: {index:"asc"}}}
      });
      return allProjects;
    } catch (error) {
      console.error('Failed to getAllProjects:', error);
      return null;
    }
  }
hard mountain
topaz warren
#

do you use next/headers?

hard mountain
#

no

hard mountain
topaz warren
hard mountain
#

its old

hard mountain
#

this version fixed their problem

topaz warren
#

oh you said you are using 14

#

ok

hard mountain
#

Do you think you could help?

#

I have been trying to solve the problem for 3-4 days but I could not find a solution.

topaz warren
#

is your project public?

hard mountain
#

no :/

#

also

export const revalidate = 60

also this didn't work :/

topaz warren
#

what happens if you try in local-production? npm run build & npm run start instead of npm run dev?

hard mountain
#

in npm run dev It gives a 404 error and that's to be expected.

#

but in local production "npm run build & npm run start" it gives 500 internal server error

#

i tried to also revalidate = 60 but still nextjs thinks the unkown pages are static

topaz warren
#

you need to debug why you get 500 in local production

hard mountain
#

🫠