@netlify/plugin-nextjs 4.37.3 → 4.37.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -87,6 +87,15 @@ const makeHandler = ({ conf, app, pageRoot, NextServer, staticManifest = [], mod
87
87
  // Next expects to be able to parse the query from the URL
88
88
  const query = new URLSearchParams(event.queryStringParameters).toString();
89
89
  event.path = query ? `${event.path}?${query}` : event.path;
90
+ if (event.headers['accept-language'] && (mode === 'odb' || event.headers['x-next-just-first-accept-language'])) {
91
+ // keep just first language to match Netlify redirect limitation:
92
+ // https://docs.netlify.com/routing/redirects/redirect-options/#redirect-by-country-or-language
93
+ // > Language-based redirects always match against the first language reported by the browser in the Accept-Language header regardless of quality value weighting.
94
+ // If we wouldn't keep just first language, it's possible for `next-server` to generate locale redirect that could be cached by ODB
95
+ // because it matches on every language listed: https://github.com/vercel/next.js/blob/5d9597879c46b383d595d6f7b37fd373325b7544/test/unit/accept-headers.test.ts
96
+ // 'x-next-just-first-accept-language' header is escape hatch to be able to hit this code for tests (both automated and manual)
97
+ event.headers['accept-language'] = event.headers['accept-language'].replace(/\s*,.*$/, '');
98
+ }
90
99
  const { headers, ...result } = await getBridge(event, context).launcher(event, context);
91
100
  // Convert all headers to multiValueHeaders
92
101
  const multiValueHeaders = getMultiValueHeaders(headers);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/plugin-nextjs",
3
- "version": "4.37.3",
3
+ "version": "4.37.4",
4
4
  "description": "Run Next.js seamlessly on Netlify",
5
5
  "main": "index.js",
6
6
  "files": [