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
c5159826
Unverified
Commit
c5159826
authored
Jul 01, 2021
by
Jiachi Liu
Committed by
GitHub
Jul 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Leverage blocked page for _error (#26748)
## Enhance simplify detection for visiting `_error` x-ref: #26610
parent
be60ef52
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
6 deletions
+3
-6
next-server.ts
packages/next/server/next-server.ts
+0
-5
constants.ts
packages/next/shared/lib/constants.ts
+1
-1
index.test.js
test/integration/client-navigation/test/index.test.js
+2
-0
No files found.
packages/next/server/next-server.ts
View file @
c5159826
...
@@ -1447,7 +1447,6 @@ export default class Server {
...
@@ -1447,7 +1447,6 @@ export default class Server {
):
Promise
<
string
|
null
>
{
):
Promise
<
string
|
null
>
{
const
is404Page
=
pathname
===
'/404'
const
is404Page
=
pathname
===
'/404'
const
is500Page
=
pathname
===
'/500'
const
is500Page
=
pathname
===
'/500'
const
isErrorPage
=
pathname
===
'/_error'
const
isLikeServerless
=
const
isLikeServerless
=
typeof
components
.
Component
===
'object'
&&
typeof
components
.
Component
===
'object'
&&
...
@@ -1466,10 +1465,6 @@ export default class Server {
...
@@ -1466,10 +1465,6 @@ export default class Server {
res
.
statusCode
=
404
res
.
statusCode
=
404
}
}
if
(
isErrorPage
&&
res
.
statusCode
===
200
)
{
res
.
statusCode
=
404
}
// ensure correct status is set when visiting a status page
// ensure correct status is set when visiting a status page
// directly e.g. /500
// directly e.g. /500
if
(
STATIC_STATUS_PAGES
.
includes
(
pathname
))
{
if
(
STATIC_STATUS_PAGES
.
includes
(
pathname
))
{
...
...
packages/next/shared/lib/constants.ts
View file @
c5159826
...
@@ -17,7 +17,7 @@ export const SERVER_DIRECTORY = 'server'
...
@@ -17,7 +17,7 @@ export const SERVER_DIRECTORY = 'server'
export
const
SERVERLESS_DIRECTORY
=
'serverless'
export
const
SERVERLESS_DIRECTORY
=
'serverless'
export
const
CONFIG_FILE
=
'next.config.js'
export
const
CONFIG_FILE
=
'next.config.js'
export
const
BUILD_ID_FILE
=
'BUILD_ID'
export
const
BUILD_ID_FILE
=
'BUILD_ID'
export
const
BLOCKED_PAGES
=
[
'/_document'
,
'/_app'
]
export
const
BLOCKED_PAGES
=
[
'/_document'
,
'/_app'
,
'/_error'
]
export
const
CLIENT_PUBLIC_FILES_PATH
=
'public'
export
const
CLIENT_PUBLIC_FILES_PATH
=
'public'
export
const
CLIENT_STATIC_FILES_PATH
=
'static'
export
const
CLIENT_STATIC_FILES_PATH
=
'static'
export
const
CLIENT_STATIC_FILES_RUNTIME
=
'runtime'
export
const
CLIENT_STATIC_FILES_RUNTIME
=
'runtime'
...
...
test/integration/client-navigation/test/index.test.js
View file @
c5159826
...
@@ -29,6 +29,7 @@ describe('Client Navigation', () => {
...
@@ -29,6 +29,7 @@ describe('Client Navigation', () => {
afterAll
(()
=>
killApp
(
context
.
server
))
afterAll
(()
=>
killApp
(
context
.
server
))
it
(
'should not reload when visiting /_error directly'
,
async
()
=>
{
it
(
'should not reload when visiting /_error directly'
,
async
()
=>
{
const
{
status
}
=
await
fetchViaHTTP
(
context
.
appPort
,
'/_error'
)
const
browser
=
await
webdriver
(
context
.
appPort
,
'/_error'
)
const
browser
=
await
webdriver
(
context
.
appPort
,
'/_error'
)
await
browser
.
eval
(
'window.hello = true'
)
await
browser
.
eval
(
'window.hello = true'
)
...
@@ -41,6 +42,7 @@ describe('Client Navigation', () => {
...
@@ -41,6 +42,7 @@ describe('Client Navigation', () => {
}
}
const
html
=
await
browser
.
eval
(
'document.documentElement.innerHTML'
)
const
html
=
await
browser
.
eval
(
'document.documentElement.innerHTML'
)
expect
(
status
).
toBe
(
404
)
expect
(
html
).
toContain
(
'This page could not be found'
)
expect
(
html
).
toContain
(
'This page could not be found'
)
expect
(
html
).
toContain
(
'404'
)
expect
(
html
).
toContain
(
'404'
)
})
})
...
...
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