Prevent background navigation from overwriting the selected language
Summary
Background locale requests could overwrite a newer language selection: /ko/blog prefetched with NEXT_LOCALE=en returned Set-Cookie: NEXT_LOCALE=ko.
Keep cookie-based locale negotiation, but omit locale-cookie writes from background responses, including Next's internal cookie header. Use browser Fetch Metadata because Next.js strips internal RSC headers before Proxy. Full document navigation still remembers its locale. No prefetching is disabled.
CI now fails when a browser test passes only on retry.
Preview: https://cmux-staging-951olkbkw-manaflow.vercel.app/ko (Ready; requires Vercel access). The verification identity is denied by Trusted Sources, so visual/browser proof uses the same source's isolated production-style build. Deployment protection is unchanged.
| Preview (English blog after switching from Korean and reloading) |
|---|
Verification
- Test-only commit
2e4b5665ab2: four new behavioral assertions fail, 3,165 existing tests pass: https://github.com/manaflow-ai/cmux/actions/runs/35042949057 - Final commit
35c3ccfe51a: 3,170 unit tests and all 9 browser tests pass in CI: https://github.com/manaflow-ai/cmux/actions/runs/35043581164 - 42 focused locale/SEO tests, typecheck, and complexity gate pass locally.
- All 5 locale browser tests repeated 20 times: 100 passed, retries disabled (4.3 minutes).
- Real-browser regression completes an English selection, then a background read from an older Korean tab sharing the cookie store. Against the original production build, it fails specifically with expected
en, receivedko; the fixed build passes. No sleeps or fabricated response cookies. - Tagged cloud reload
lcr19-08f6c4d0333bsucceeded. No native app behavior changed. - Browser proof: navigated Korean home → Korean blog → selected English → reloaded. URL remained
/blog, cookie remainedNEXT_LOCALE=en.
No user-facing strings changed. Korean, Japanese, Arabic, and English locale behavior remains covered.