Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
2bc8e740
Unverified
Commit
2bc8e740
authored
Jan 17, 2023
by
JJ Kasper
Committed by
GitHub
Jan 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update res.revalidate to pass through headers (#44981)
parent
09830502
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
5 deletions
+17
-5
node.ts
packages/next/src/server/api-utils/node.ts
+17
-5
No files found.
packages/next/src/server/api-utils/node.ts
View file @
2bc8e740
...
...
@@ -353,6 +353,15 @@ function setPreviewData<T>(
return
res
}
const
filteredRevalidateHeaders
=
new
Set
([
'content-type'
,
'content-encoding'
,
'accept'
,
'accept-language'
,
'accept-encoding'
,
'connection'
,
])
async
function
revalidate
(
urlPath
:
string
,
opts
:
{
...
...
@@ -366,7 +375,7 @@ async function revalidate(
`Invalid urlPath provided to revalidate(), must be a path e.g. /blog/post-1, received
${
urlPath
}
`
)
}
const
revalidateHeaders
=
{
const
revalidateHeaders
:
HeadersInit
=
{
[
PRERENDER_REVALIDATE_HEADER
]:
context
.
previewModeId
,
...(
opts
.
unstable_onlyGenerated
?
{
...
...
@@ -375,14 +384,17 @@ async function revalidate(
:
{}),
}
for
(
const
key
of
Object
.
keys
(
req
.
headers
))
{
if
(
!
filteredRevalidateHeaders
.
has
(
key
)
&&
!
key
.
startsWith
(
'x-vercel'
))
{
revalidateHeaders
[
key
]
=
req
.
headers
[
key
]
as
string
}
}
try
{
if
(
context
.
trustHostHeader
)
{
const
res
=
await
fetch
(
`https://
${
req
.
headers
.
host
}${
urlPath
}
`
,
{
method
:
'HEAD'
,
headers
:
{
...
revalidateHeaders
,
cookie
:
req
.
headers
.
cookie
||
''
,
},
headers
:
revalidateHeaders
,
})
// we use the cache header to determine successful revalidate as
// a non-200 status code can be returned from a successful revalidate
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment