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
43a70c7e
Unverified
Commit
43a70c7e
authored
Feb 21, 2020
by
Joe Haddad
Committed by
GitHub
Feb 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Cookie Expiration (#10634)
parent
ee7ea03a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
api-utils.ts
packages/next/next-server/server/api-utils.ts
+8
-2
index.test.js
test/integration/prerender-preview/test/index.test.js
+5
-2
No files found.
packages/next/next-server/server/api-utils.ts
View file @
43a70c7e
...
@@ -414,13 +414,19 @@ function clearPreviewData<T>(res: NextApiResponse<T>): NextApiResponse<T> {
...
@@ -414,13 +414,19 @@ function clearPreviewData<T>(res: NextApiResponse<T>): NextApiResponse<T> {
?
previous
?
previous
:
[]),
:
[]),
serialize
(
COOKIE_NAME_PRERENDER_BYPASS
,
''
,
{
serialize
(
COOKIE_NAME_PRERENDER_BYPASS
,
''
,
{
maxAge
:
0
,
// To delete a cookie, set `expires` to a date in the past:
// https://tools.ietf.org/html/rfc6265#section-4.1.1
// `Max-Age: 0` is not valid, thus ignored, and the cookie is persisted.
expires
:
new
Date
(
0
),
httpOnly
:
true
,
httpOnly
:
true
,
sameSite
:
'strict'
,
sameSite
:
'strict'
,
path
:
'/'
,
path
:
'/'
,
}),
}),
serialize
(
COOKIE_NAME_PRERENDER_DATA
,
''
,
{
serialize
(
COOKIE_NAME_PRERENDER_DATA
,
''
,
{
maxAge
:
0
,
// To delete a cookie, set `expires` to a date in the past:
// https://tools.ietf.org/html/rfc6265#section-4.1.1
// `Max-Age: 0` is not valid, thus ignored, and the cookie is persisted.
expires
:
new
Date
(
0
),
httpOnly
:
true
,
httpOnly
:
true
,
sameSite
:
'strict'
,
sameSite
:
'strict'
,
path
:
'/'
,
path
:
'/'
,
...
...
test/integration/prerender-preview/test/index.test.js
View file @
43a70c7e
...
@@ -106,6 +106,7 @@ function runTests() {
...
@@ -106,6 +106,7 @@ function runTests() {
const
cookies
=
res
.
headers
const
cookies
=
res
.
headers
.
get
(
'set-cookie'
)
.
get
(
'set-cookie'
)
.
replace
(
/
(
=
\w{3})
,/g
,
'$1'
)
.
split
(
','
)
.
split
(
','
)
.
map
(
cookie
.
parse
)
.
map
(
cookie
.
parse
)
...
@@ -113,15 +114,17 @@ function runTests() {
...
@@ -113,15 +114,17 @@ function runTests() {
expect
(
cookies
[
0
]).
toMatchObject
({
expect
(
cookies
[
0
]).
toMatchObject
({
Path
:
'/'
,
Path
:
'/'
,
SameSite
:
'Strict'
,
SameSite
:
'Strict'
,
'Max-Age'
:
'0
'
,
Expires
:
'Thu 01 Jan 1970 00:00:00 GMT
'
,
})
})
expect
(
cookies
[
0
]).
toHaveProperty
(
'__prerender_bypass'
)
expect
(
cookies
[
0
]).
toHaveProperty
(
'__prerender_bypass'
)
expect
(
cookies
[
0
]).
not
.
toHaveProperty
(
'Max-Age'
)
expect
(
cookies
[
1
]).
toMatchObject
({
expect
(
cookies
[
1
]).
toMatchObject
({
Path
:
'/'
,
Path
:
'/'
,
SameSite
:
'Strict'
,
SameSite
:
'Strict'
,
'Max-Age'
:
'0
'
,
Expires
:
'Thu 01 Jan 1970 00:00:00 GMT
'
,
})
})
expect
(
cookies
[
1
]).
toHaveProperty
(
'__next_preview_data'
)
expect
(
cookies
[
1
]).
toHaveProperty
(
'__next_preview_data'
)
expect
(
cookies
[
1
]).
not
.
toHaveProperty
(
'Max-Age'
)
})
})
/** @type import('next-webdriver').Chain */
/** @type import('next-webdriver').Chain */
...
...
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