Next.js Discord

Discord Forum

Getting 500 error instead of 404 after the Build

Answered
Mini Satin posted this in #help-forum
Open in Discord
Mini SatinOP
Using version: 14.2.3

I don't get any 500 errors when I'm in development mode. But after I get the build, when I start it with "npm run start" I get a 500 error instead of a 404 error

app/en/g/[slug]/page.tsx
import db from "@/db/drizzle";
import { eq } from "drizzle-orm";
import { games } from "./schema";
import { notFound } from "next/navigation";
import { GameSection } from "./game-section";

interface Props {
  params: {
    slug: string;
  };
}

export async function generateStaticParams() {
  const gamez = await db.query.games.findMany()

  return gamez.map(game => ({slug: game.slug}))
}

const Page = async ({ params }: Props) => {
  const game = await db.query.games.findFirst({
    where: eq(games.slug, params.slug)
  })

  if(!game) return notFound()

  return (
    <GameSection game={game} />
  )
};

export default Page;


dev mode:
Answered by joulev
try adding export const dynamicParams = false
View full answer

3 Replies