You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: pass only first language to next-server to match platform redirects support (#2138)
* fix: pass only first language to next-server to match platform redirects support
* test: add test case
* test: some cleanup in cypress test, extra assertion and some more comments
* fix: apply accept-language filtering only in ODB mode
* test: add escape hatch to use ~odb handling when not actually using odb
---------
Co-authored-by: Rob Stanford <[email protected]>
// > Language-based redirects always match against the first language reported by the browser in the Accept-Language header regardless of quality value weighting.
48
+
// while Next.js matches on every language: https://github.com/vercel/next.js/blob/5d9597879c46b383d595d6f7b37fd373325b7544/test/unit/accept-headers.test.ts
49
+
'Accept-Language': 'jp, fr;q=0.9',
50
+
// make sure we don't use cached results
51
+
cookie: '__prerender_bypass=1',
52
+
// above cookie header cause us to hit non-ODB function variant
53
+
// below header allow us to force ODB-only code path despite not running ODB (this is just for testing purposes)
54
+
'x-next-just-first-accept-language': '1',
55
+
},
56
+
}).then((response)=>{
57
+
// make sure we didn't hit SSR handler - not ODB and nothing else handles this request
58
+
// once platform starts supporting more languages in Accept-Language header - this test
59
+
// will start failing because then we will get platform level redirect
// > Language-based redirects always match against the first language reported by the browser in the Accept-Language header regardless of quality value weighting.
137
+
// If we wouldn't keep just first language, it's possible for `next-server` to generate locale redirect that could be cached by ODB
138
+
// because it matches on every language listed: https://github.com/vercel/next.js/blob/5d9597879c46b383d595d6f7b37fd373325b7544/test/unit/accept-headers.test.ts
139
+
// 'x-next-just-first-accept-language' header is escape hatch to be able to hit this code for tests (both automated and manual)
0 commit comments