Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6f9b51f

Browse files
committed
Remove pageNotFound key from the error.
1 parent 866319c commit 6f9b51f

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

lib/error.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ import Head from './head'
55
export default class Error extends React.Component {
66
static getInitialProps ({ res, err }) {
77
const statusCode = res ? res.statusCode : (err ? err.statusCode : null)
8-
const pageNotFound = statusCode === 404 || (err ? err.pageNotFound : false)
9-
return { statusCode, pageNotFound }
8+
return { statusCode }
109
}
1110

1211
render () {
13-
const { statusCode, pageNotFound } = this.props
14-
const title = pageNotFound
12+
const { statusCode } = this.props
13+
const title = statusCode === 404
1514
? 'This page could not be found'
1615
: HTTPStatus[statusCode] || 'An unexpected error has occurred'
1716

lib/router/router.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export default class Router {
208208
return { error: err }
209209
}
210210

211-
if (err.pageNotFound) {
211+
if (err.statusCode === 404) {
212212
// Indicate main error display logic to
213213
// ignore rendering this error as a runtime error.
214214
err.ignore = true

server/render.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ export async function renderScriptError (req, res, page, error, customFields, op
124124
res.end(`
125125
function loadPage () {
126126
var error = new Error('Page not exists: ${page}')
127-
error.pageNotFound = true
128127
error.statusCode = 404
129128
__NEXT_PAGE_LOADER__.registerPage('${page}', function(cb) {
130129
cb(error)

0 commit comments

Comments
 (0)