You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem
I followed the official next-intl documentation to set up i18n.
However, I noticed that requestLocale is always undefined inside getRequestConfig, even when I access routes like /en, /ko.
(Since it is undefined, it always return the default locale set inside the routing.js)
Here’s the relevant part of my code:
// i18n/request.js
import { getRequestConfig } from "next-intl/server";
import { hasLocale } from "next-intl";
import { routing } from "./routing";
export default getRequestConfig(async ({ requestLocale }) => {
console.log("requested", requestLocale); // always undefined
const locale = hasLocale(routing.locales, requestLocale)
? requestLocale
: routing.defaultLocale;
console.log("final locale", locale);
return {
locale,
messages: (await import(`../../messages/${locale}.json`)).default,
};
});
// Console output:
// requested undefined
// final locale ko
ko is my default locale.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Environment
Next.js: 14.2.26
next-intl: 4.1.0
Problem
I followed the official next-intl documentation to set up i18n.
However, I noticed that requestLocale is always undefined inside getRequestConfig, even when I access routes like /en, /ko.
(Since it is undefined, it always return the default locale set inside the routing.js)
Here’s the relevant part of my code:
Even when I access http://localhost:3000/en, requestLocale is still undefined.
Additional Info

In root layout.js, when Iconsole log the locale params, it returns well.
My middleware.js is set up exactly as shown in the next-intl documentation.
Question
How should I fix my request.js to make it work properly?
Thanks in advance for any help!
Beta Was this translation helpful? Give feedback.
All reactions