Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Commit 0b94cc3

Browse files
committed
update logic
1 parent d894188 commit 0b94cc3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/libs/core/src/route/locale.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,14 @@ export async function getLocaleDomainRedirect(
149149
: undefined;
150150
// Use cookies first, otherwise use the accept-language header
151151
let acceptLanguages: string[] = [];
152+
let nextLocale;
152153
if (headerCookies) {
153154
const cookies = parse(headerCookies);
154-
const nextLocale = cookies["NEXT_LOCALE"];
155-
if (nextLocale) {
156-
acceptLanguages = [nextLocale.toLowerCase()];
157-
}
155+
nextLocale = cookies["NEXT_LOCALE"];
156+
}
157+
158+
if (nextLocale) {
159+
acceptLanguages = [nextLocale.toLowerCase()];
158160
} else {
159161
const Accept = await import("@hapi/accept");
160162
acceptLanguages = Accept.languages(acceptLanguage).map((lang) =>

0 commit comments

Comments
 (0)