I follow NextJS documentation on Prefixing defaultLocale however, I’m facing build error when I run yarn build
> Export encountered errors on following paths:
/: /default
/_error: /404
/_error: /500
/_error: /default/404
/_error: /default/500
/about: /default/about
/apply: /default/apply
...
I suspect that it has to do with getStaticProps
and locale
to fetch some of my content.
export async function getStaticProps({ locale }: { locale: string }) {
const lang = locale.split("-")[0] as Locale;
const pageData = apply[lang];
return {
props: {
pageData,
},
};
}
I tried to conditionally update the content of lang
as such:
const lang = locale !== 'default' ? locale.split("-")[0] as Locale : 'fr' as Locale;
I still get the error.