We have a very simple code that works perfectly on client side, but fails on the server side on a production build.
This does not happen when using the dev server though.
Code
export default defineNuxtRouteMiddleware(() => {
const { locale } = useNuxtApp().$i18n;
const dayjs = useDayjs();
if (locale.value !== dayjs.locale()) {
console.log("Setting dayjs locale to", locale.value);
dayjs.locale(locale.value);
console.log("Dayjs locale is now set to", dayjs.locale());
}
});
Output
Setting dayjs locale to de
Dayjs locale is now set to en
Here I'd expect the server to put out "de" twice, but setting the locale simply does nothing.
Config
locales: i18nConfig.locales,
plugins: ["localeData", "localizedFormat", "utc", "customParseFormat"],
defaultLocale: 'en',
We have a very simple code that works perfectly on client side, but fails on the server side on a production build.
This does not happen when using the dev server though.
Code
Output
Here I'd expect the server to put out "de" twice, but setting the locale simply does nothing.
Config