From 00e3a4be19bf8428ea6ce1ed2ae74a8ac8375532 Mon Sep 17 00:00:00 2001 From: Rob Stanford Date: Fri, 1 Nov 2024 17:29:17 +0000 Subject: [PATCH] fix: add data request query param to the cache key (#2701) * fix: vary cache key on __nextDataReq query param * test: update header tests to check for new vary param --- src/run/headers.test.ts | 14 +++++++------- src/run/headers.ts | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/run/headers.test.ts b/src/run/headers.test.ts index 4ca423e402..f20bee6a41 100644 --- a/src/run/headers.test.ts +++ b/src/run/headers.test.ts @@ -40,7 +40,7 @@ describe('headers', () => { expect(headers.set).toBeCalledWith( 'netlify-vary', - 'header=x-nextjs-data|x-next-debug-logging,cookie=__prerender_bypass|__next_preview_data', + 'query=__nextDataReq,header=x-nextjs-data|x-next-debug-logging,cookie=__prerender_bypass|__next_preview_data', ) }) @@ -56,7 +56,7 @@ describe('headers', () => { expect(headers.set).toBeCalledWith( 'netlify-vary', - 'header=x-nextjs-data|x-next-debug-logging|Accept|Accept-Language,cookie=__prerender_bypass|__next_preview_data', + 'query=__nextDataReq,header=x-nextjs-data|x-next-debug-logging|Accept|Accept-Language,cookie=__prerender_bypass|__next_preview_data', ) }) @@ -77,7 +77,7 @@ describe('headers', () => { expect(headers.set).toBeCalledWith( 'netlify-vary', - 'header=x-nextjs-data|x-next-debug-logging,cookie=__prerender_bypass|__next_preview_data', + 'query=__nextDataReq,header=x-nextjs-data|x-next-debug-logging,cookie=__prerender_bypass|__next_preview_data', ) }) @@ -97,7 +97,7 @@ describe('headers', () => { expect(headers.set).toBeCalledWith( 'netlify-vary', - 'header=x-nextjs-data|x-next-debug-logging,cookie=__prerender_bypass|__next_preview_data', + 'query=__nextDataReq,header=x-nextjs-data|x-next-debug-logging,cookie=__prerender_bypass|__next_preview_data', ) }) @@ -117,7 +117,7 @@ describe('headers', () => { expect(headers.set).toBeCalledWith( 'netlify-vary', - 'header=x-nextjs-data|x-next-debug-logging,language=en|de|fr,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE', + 'query=__nextDataReq,header=x-nextjs-data|x-next-debug-logging,language=en|de|fr,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE', ) }) @@ -138,7 +138,7 @@ describe('headers', () => { expect(headers.set).toBeCalledWith( 'netlify-vary', - 'header=x-nextjs-data|x-next-debug-logging,language=en|de|fr,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE', + 'query=__nextDataReq,header=x-nextjs-data|x-next-debug-logging,language=en|de|fr,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE', ) }) @@ -185,7 +185,7 @@ describe('headers', () => { expect(headers.set).toBeCalledWith( 'netlify-vary', - 'query=item_id|page|per_page,header=x-nextjs-data|x-next-debug-logging|x-custom-header,language=en|de|fr|es,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE|ab_test,country=es', + 'query=__nextDataReq|item_id|page|per_page,header=x-nextjs-data|x-next-debug-logging|x-custom-header,language=en|de|fr|es,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE|ab_test,country=es', ) }) }) diff --git a/src/run/headers.ts b/src/run/headers.ts index 12c56871a5..e1ad53e37d 100644 --- a/src/run/headers.ts +++ b/src/run/headers.ts @@ -81,7 +81,7 @@ export const setVaryHeaders = ( header: ['x-nextjs-data', 'x-next-debug-logging'], language: [], cookie: ['__prerender_bypass', '__next_preview_data'], - query: [], + query: ['__nextDataReq'], country: [], }