diff --git a/app/components/Header.tsx b/app/components/Header.tsx index 95ac994..441230f 100644 --- a/app/components/Header.tsx +++ b/app/components/Header.tsx @@ -49,10 +49,14 @@ const Header = () => { 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}`); - router.refresh(); + // Use a hard navigation for maximum reliability (also fixes cases where + // client-side router navigation can be prevented by runtime errors). + const target = `/${nextLocale}${pathWithoutLocale}${hash}`; + if (typeof window !== "undefined") { + window.location.assign(target); + return; + } + router.push(target); } catch { // ignore }