From c150cd82d931714a87f574bfd92ff194022c3149 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 14 Jan 2026 16:21:18 +0000 Subject: [PATCH] fix(i18n): make locale switch always navigate Stop setting NEXT_LOCALE cookie client-side and refresh after navigation, avoiding swallowed cookie errors that can prevent router.push from switching languages. Co-authored-by: dennis --- app/components/Header.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/components/Header.tsx b/app/components/Header.tsx index 54604d1..95ac994 100644 --- a/app/components/Header.tsx +++ b/app/components/Header.tsx @@ -48,8 +48,11 @@ const Header = () => { try { const pathWithoutLocale = pathname.replace(new RegExp(`^/${locale}`), "") || ""; const hash = typeof window !== "undefined" ? window.location.hash : ""; + // Rely on middleware to persist NEXT_LOCALE cookie. + // Avoid setting cookies from the client here; in some environments this can throw + // and prevent navigation. router.push(`/${nextLocale}${pathWithoutLocale}${hash}`); - document.cookie = `NEXT_LOCALE=${nextLocale}; path=/`; + router.refresh(); } catch { // ignore }