Explorar o código

fix: locale match error (#115)

Joel hai 1 ano
pai
achega
96809108ca
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      web/middleware.ts

+ 5 - 1
web/middleware.ts

@@ -23,7 +23,11 @@ export const getLocale = (request: NextRequest): Locale => {
   }
 
   // match locale
-  const matchedLocale = match(languages, locales, i18n.defaultLocale) as Locale
+  let matchedLocale:Locale  = i18n.defaultLocale
+  try {
+    // If languages is ['*'], Error would happen in match function.
+    matchedLocale = match(languages, locales, i18n.defaultLocale) as Locale
+  } catch(e) {}
   return matchedLocale
 }