Route group + [...rest] populating locale with non-locale values #1911
-
DescriptionHey! When you use route group *****************
WebLayout locale: en
*****************
*****************
WebLayout locale: .well-known
***************** This is only repro, it can get very out of the hand, for example these logs are from my prod: > next start -p 3001
▲ Next.js 15.3.2
- Local: http://localhost:3001/
- Network: http://10.250.18.70:3001/
✓ Starting...
✓ Ready in 869ms
Locale .well-known is not supported. Defaulting to 'sk'
Locale .well-known is not supported. Defaulting to 'sk'
Locale .well-known is not supported. Defaulting to 'sk'
Locale _next is not supported. Defaulting to 'sk'
Locale _next is not supported. Defaulting to 'sk'
Locale _next is not supported. Defaulting to 'sk'
Locale _next is not supported. Defaulting to 'sk'
Locale _next is not supported. Defaulting to 'sk'
Locale _next is not supported. Defaulting to 'sk'
Locale apple-touch-icon-precomposed.png is not supported. Defaulting to 'sk'
Locale apple-touch-icon-precomposed.png is not supported. Defaulting to 'sk'
Locale apple-touch-icon-precomposed.png is not supported. Defaulting to 'sk'
Locale apple-touch-icon.png is not supported. Defaulting to 'sk'
Locale apple-touch-icon.png is not supported. Defaulting to 'sk'
Locale apple-touch-icon.png is not supported. Defaulting to 'sk'
Locale _next is not supported. Defaulting to 'sk'
Locale _next is not supported. Defaulting to 'sk'
Locale _next is not supported. Defaulting to 'sk'
Locale _next is not supported. Defaulting to 'sk'
Locale _next is not supported. Defaulting to 'sk'
Locale _next is not supported. Defaulting to 'sk' Verifications
Mandatory reproduction URLhttps://github.com/MichalMoravik/next-intl-bug Reproduction descriptionSteps to reproduce:
Expected behaviourWell I expect the locale to either be "en" or "sk" (in my prod), not other values such as This is causing a flood of error logs in my production. It seems to NOT affect the web functioning, at least not something users can see. Maybe it causes issues in the background, too many re-renders or something similar, I don't know about that part. Thank you for taking your time to look at this!! 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Alright, when I move the But the problem is, that I want this "catch all not found" mechanism to work underneath Any idea what is happening? This is interesting. |
Beta Was this translation helpful? Give feedback.
-
Your browser can request files like You'll see this value in your logs because you're only validating the received locale in If you need the locale in other places in your app, I'd suggest to read from More information on parallel rendering of layouts and pages in Next.js and validation: #1722 I'll move this to a discussion since it's a usage question. |
Beta Was this translation helpful? Give feedback.
-
Hey @amannn, thanks for the answer. I've added the I'm not sure I fully understand the second part of your answer - locale. It's unclear to me when I should grab locale from the params and when I should call More context: Until recently, I was grabbing the locale from params only in the LocaleLayout ( export const generateMetadata = async ({
params,
}: {
params: Promise<{ locale: string }>;
}): Promise<Metadata> => {
const { locale } = await params;
const tm = await getTranslations({ locale, namespace: 'Metadata' });
return {
title: tm('checkout'),
};
}; My pages and other components used (and still use) As I'm growing and adding this new route group (in the example it's Are you saying that I should use If so, what's the difference? When should one use the locale from params vs from the function/s? Looking at the next-intl example, even the page grabs the locale from params, which makes me a slightly more confused. Thanks a lot, I appreciate the insights :) |
Beta Was this translation helpful? Give feedback.
-
Hi @amannn, could you help me out in my answer above please? 🙏 I couldn't find info on that topic in the docs. Thanks a lot :) |
Beta Was this translation helpful? Give feedback.
Your browser can request files like
/.well-known/appspecific/com.chrome.devtools.json
automatically (source). In this case, if you don't support this file, you should return a 404 (which is what you're doing).You'll see this value in your logs because you're only validating the received locale in
[locale]/layout.tsx
. Layouts and pages render in parallel, therefore your log entry in(web)/layout.tsx
might see an invalid[locale]
value before the validation triggersnotFound()
.If you need the locale in other places in your app, I'd suggest to read from
getLocale
.More information on parallel rendering of layouts and pages in Next.js and validation: #1722
I'll move this to a discussion sin…