nextjs 14 app in production throws 500:internal server error instead of 404 not found page
Unanswered
Asari posted this in #help-forum
AsariOP
hello , nextjs 14 app with next-intl ->
(main)/[locale]/projects/[projectsSlugName]/page.tsx
(the relevant parts of the page are below),
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 :
if i remove the generateStaticParams page returns 404 in both dev mode and production mode as it should be.
(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: headersif i remove the generateStaticParams page returns 404 in both dev mode and production mode as it should be.
26 Replies
can you show me this func?
getAllProjects ?and from your error message I think 500 error code is correct not 404
@James4u can you show me this func? `getAllProjects` ?
AsariOP
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;
}
}@James4u and from your error message I think 500 error code is correct not 404
AsariOP
when i try to /tr/project/123123 in dev mode it returns 404
do you use next/headers?
AsariOP
no
@Asari when i try to /tr/project/123123 in dev mode it returns 404
AsariOP
in production same route returns 500
https://github.com/vercel/next.js/issues/45068
I think this is the similar issue
I think this is the similar issue
AsariOP
its old
@James4u https://github.com/vercel/next.js/issues/45068
I think this is the similar issue
AsariOP
Hi, this has been updated in v13.1.6-canary.0 of Next.js, please update and give it a try!
this version fixed their problem
oh you said you are using 14
ok
AsariOP
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.
is your project public?
AsariOP
no :/
also
also this didn't work :/
export const revalidate = 60also this didn't work :/
what happens if you try in local-production?
npm run build & npm run start instead of npm run dev?AsariOP
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
@Asari but in local production "npm run build & npm run start" it gives 500 internal server error
if you get 500 in your local production, getting 500 in production is reasonable
you need to debug why you get 500 in local production
AsariOP
🫠
I have read all the documentation, but since I can't do anything, I am requesting help from this section.