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
944668c6
Commit
944668c6
authored
Feb 01, 2018
by
Arunoda Susiripala
Committed by
Tim Neutkens
Feb 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle page 404 properly in production. (#3648)
This is needed for multi-zones feature
parent
80fc0f45
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
index.js
server/index.js
+8
-0
No files found.
server/index.js
View file @
944668c6
...
...
@@ -3,6 +3,7 @@ import { resolve, join, sep } from 'path'
import
{
parse
as
parseUrl
}
from
'url'
import
{
parse
as
parseQs
}
from
'querystring'
import
fs
from
'fs'
import
fsAsync
from
'mz/fs'
import
http
,
{
STATUS_CODES
}
from
'http'
import
{
renderToHTML
,
...
...
@@ -216,6 +217,13 @@ export default class Server {
}
const
p
=
join
(
this
.
dir
,
this
.
dist
,
'bundles'
,
'pages'
,
`
${
page
}
.js`
)
// [production] If the page is not exists, we need to send a proper Next.js style 404
// Otherwise, it'll affect the multi-zones feature.
if
(
!
(
await
fsAsync
.
exists
(
p
)))
{
return
await
renderScriptError
(
req
,
res
,
page
,
{
code
:
'ENOENT'
},
{},
this
.
renderOpts
)
}
await
this
.
serveStatic
(
req
,
res
,
p
)
},
...
...
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