Open AvaN0x opened 10 months ago
I found a fix to the issue (the repro has been updated accordingly) with a call to setStaticParamsLocale
in the generateMetadata
function.
This is related to this part of the code that'll check the headers if no staticParams were found:
https://github.com/QuiiBz/next-international/blob/e4acd2fdf3c6ec181e218df82477f05df90c7311/packages/next-international/src/app/server/get-locale-cache.tsx#L19-L31
But I still get locale not found a.a
logs in the layout by clicking the link in the repro.
It would be nice if the params.locale
value was always a valid locale.
Because of that, I have to add a check before passing the value to setStaticParamsLocale
or redirect myself to the not found page.
locales
and fallbackLocale
are coming from my locales/shared.ts
file.
It would be nice if the params.locale value was always a valid locale.
Agree, that's why we use generateStaticParams
to make sure the dynamic params are valid. This again seems like a bug with Next.js, I'll have to dig more.
Describe the bug A clear and concise description of what the bug is.
Hello, I get a app-static-to-dynamic-error error when I go in a route that is not matched by the middleware.
To Reproduce Steps to reproduce the behavior:
I also see that, when the path do not match the middleware, it'll still use the first part as the locale, this can be seein with the log
locale not found a.a
in the console.Expected behavior I'd expect the not-found page to show, instead I get a 500 error. The error disappear when you remove the use of
getI18n
in thegenerateMetadata
function in[locale]/layout.ts
. The error does not occur innpm run dev
.About (please complete the following information):
Infos about the repro
npx create-next-app@latest
[locale]/layout.ts
RootLayout to know if the locale params is indeed a locale or something elseI can provide more infos if needed