Skip to content
Notes

Next.js: an unknown [lang] served the home page with a 200

Opening /feed.xml or /wp-login.php on the site returned the home page with a 200 instead of a 404. Why: the [lang] segment accepts any value, and proxy.ts skips paths that contain a dot.

The fix is one line: forbid unknown params in the layout that has generateStaticParams.

src/app/[lang]/layout.tsx
export const dynamicParams = false;
 
export function generateStaticParams() {
  return locales.map(lang => ({ lang }));
}

Now only uz and en exist; everything else is a real 404.

  • nextjs
  • seo