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
I ran into a bug where crawlers for Google etc. were saying my homepage was returning a 500. I had the following code that's fairly standard on Next to get the best locale for a visitor and to redirect:
// Use negotiator and intl-localematcher to get best localeletlanguages=newNegotiator({headers: negotiatorHeaders,}).languages()// @ts-ignore locales are readonlyconstlocales: string[]=i18n.locales// library doesn't support wildcard so we need to handle it manuallyif((languages[0]="*")){languages=["en"]}returnmatchLocale(languages,locales,i18n.defaultLocale)
The issue was that these crawlers did not have any preferred languages in their headers, instead they had ['*'] and when passed into formatjs, it was causing an error.
Could it be good to handle the wildcard inside the match function?
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
-
Hello,
I ran into a bug where crawlers for Google etc. were saying my homepage was returning a 500. I had the following code that's fairly standard on Next to get the best locale for a visitor and to redirect:
The issue was that these crawlers did not have any preferred languages in their headers, instead they had
['*']
and when passed into formatjs, it was causing an error.Could it be good to handle the wildcard inside the match function?
Beta Was this translation helpful? Give feedback.
All reactions