From 7dada33c8a0b0abfcf30aa641974a08eeaf55f66 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Thu, 10 Oct 2024 12:00:50 -0700 Subject: [PATCH] fix: reject non-matching locales --- app/[locale]/layout.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx index d4a236a1..15142098 100644 --- a/app/[locale]/layout.tsx +++ b/app/[locale]/layout.tsx @@ -10,12 +10,17 @@ import I18NextClientProvider from "@/contexts/i18next"; import { AuthenticationContextProvider } from "@/contexts/Authentication"; import PageWrapper from "@/components/organisms/PageWrapper"; import RootScripts from "./scripts"; +import { notFound } from "next/navigation"; const GOOGLE_APP_ID = process.env.NEXT_PUBLIC_GOOGLE_APP_ID || ""; export async function generateMetadata({ params: { locale }, }: LocaleProps): Promise { + if (!languages.includes(locale)) { + notFound(); + } + const { siteInfo: metadata } = await getGlobalData(locale); const { siteTitle, siteDescription, siteImage, language } = metadata; const { url, width, height, altText: alt } = siteImage[0]; @@ -53,6 +58,10 @@ const LocaleLayout: FunctionComponent> = async ({ params: { locale }, children, }) => { + if (!languages.includes(locale)) { + notFound(); + } + return (