#Match media returns error

1 messages · Page 1 of 1 (latest)

woven bronze
#
function getLocale(request: NextRequest): string | undefined {
  // Negotiator expects plain object so we need to transform headers
  const negotiatorHeaders: Record<string, string> = {};
  request.headers.forEach((value, key) => (negotiatorHeaders[key] = value));
  // Use negotiator and intl-localematcher to get best locale
  let languages = new Negotiator({ headers: negotiatorHeaders }).languages();
  try {
    return matchLocale(languages, locales, 'pl');
  } catch {
    return 'pl';
  }
}

throws error on edge

RangeError: Incorrect locale information provided
mild lynxBOT
#

Hi @woven bronze. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: