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
0e29a2d0
Unverified
Commit
0e29a2d0
authored
Sep 14, 2021
by
Tobias Koppers
Committed by
GitHub
Sep 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reload the page to show 404 when receiving `invalid` event from on-demand-entries (#29074)
parent
07fe406b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
on-demand-entries-utils.js
packages/next/client/dev/on-demand-entries-utils.js
+13
-2
No files found.
packages/next/client/dev/on-demand-entries-utils.js
View file @
0e29a2d0
...
@@ -33,13 +33,24 @@ export function setupPing(assetPrefix, pathnameFn, retry) {
...
@@ -33,13 +33,24 @@ export function setupPing(assetPrefix, pathnameFn, retry) {
// the dev overlay as this can cause the error to be triggered
// the dev overlay as this can cause the error to be triggered
// repeatedly
// repeatedly
if
(
payload
.
invalid
&&
!
self
.
__NEXT_DATA__
.
err
)
{
if
(
payload
.
invalid
&&
!
self
.
__NEXT_DATA__
.
err
)
{
// Payload can be invalid even if the page does
not
exist.
// Payload can be invalid even if the page does exist.
// So, we
need to make sure it exists before reloading
.
// So, we
check if it can be created
.
fetch
(
location
.
href
,
{
fetch
(
location
.
href
,
{
credentials
:
'same-origin'
,
credentials
:
'same-origin'
,
}).
then
((
pageRes
)
=>
{
}).
then
((
pageRes
)
=>
{
if
(
pageRes
.
status
===
200
)
{
if
(
pageRes
.
status
===
200
)
{
// Page exists now, reload
location
.
reload
()
location
.
reload
()
}
else
{
// Page doesn't exist
if
(
self
.
__NEXT_DATA__
.
page
===
currentPage
&&
currentPage
!==
'/_error'
)
{
// We are still on the page,
// reload to show 404 error page
location
.
reload
()
}
}
}
})
})
}
}
...
...
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