Skip to content

Commit

Permalink
fix: add data request query param to the cache key (#2701)
Browse files Browse the repository at this point in the history
* fix: vary cache key on __nextDataReq query param

* test: update header tests to check for new vary param
  • Loading branch information
orinokai authored Nov 1, 2024
1 parent d3d2fb5 commit 00e3a4b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/run/headers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
})

Expand All @@ -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',
)
})

Expand All @@ -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',
)
})

Expand All @@ -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',
)
})

Expand All @@ -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',
)
})

Expand All @@ -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',
)
})

Expand Down Expand Up @@ -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',
)
})
})
Expand Down
2 changes: 1 addition & 1 deletion src/run/headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
}

Expand Down

0 comments on commit 00e3a4b

Please sign in to comment.