Skip to content

Commit

Permalink
bugfix(website): fix middleware region redirect (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkue authored Dec 1, 2023
1 parent 5cb7eb6 commit 8a2d5b9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions website/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const findBestLocale = (
}

const options = langParser.parse(request.headers.get('Accept-Language') || 'en');
const requestCountry = request.geo?.country;
const requestCountry = request.geo?.country?.toLowerCase() as WebsiteRegion | undefined;
console.info('Country set in request header:', requestCountry);

const bestOption = options.find(
Expand All @@ -54,7 +54,7 @@ export const findBestLocale = (
return {
language: (bestOption?.code as WebsiteLanguage) || defaultLanguage,
region:
(websiteRegions.includes(requestCountry?.toLowerCase() as WebsiteRegion) && (requestCountry as WebsiteRegion)) ||
(requestCountry && websiteRegions.includes(requestCountry) && requestCountry) ||
(bestOption?.region as WebsiteRegion) ||
defaultRegion,
};
Expand Down

0 comments on commit 8a2d5b9

Please sign in to comment.