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
633dd87b
Unverified
Commit
633dd87b
authored
Nov 30, 2018
by
Tim Neutkens
Committed by
GitHub
Nov 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle 404 thrown from send (#5779)
parent
4322bb13
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
next-server.js
packages/next-server/server/next-server.js
+1
-1
index.test.js
test/integration/production/test/index.test.js
+6
-0
No files found.
packages/next-server/server/next-server.js
View file @
633dd87b
...
@@ -231,7 +231,7 @@ export default class Server {
...
@@ -231,7 +231,7 @@ export default class Server {
try
{
try
{
return
await
serveStatic
(
req
,
res
,
path
)
return
await
serveStatic
(
req
,
res
,
path
)
}
catch
(
err
)
{
}
catch
(
err
)
{
if
(
err
.
code
===
'ENOENT'
)
{
if
(
err
.
code
===
'ENOENT'
||
err
.
statusCode
===
404
)
{
this
.
render404
(
req
,
res
)
this
.
render404
(
req
,
res
)
}
else
{
}
else
{
throw
err
throw
err
...
...
test/integration/production/test/index.test.js
View file @
633dd87b
...
@@ -61,6 +61,12 @@ describe('Production Usage', () => {
...
@@ -61,6 +61,12 @@ describe('Production Usage', () => {
expect
(
res
.
status
).
toBe
(
404
)
expect
(
res
.
status
).
toBe
(
404
)
})
})
it
(
'should render 404 for dotfiles in /static'
,
async
()
=>
{
const
url
=
`http://localhost:
${
appPort
}
/static/.env`
const
res
=
await
fetch
(
url
)
expect
(
res
.
status
).
toBe
(
404
)
})
it
(
'should render 501 if the HTTP method is not GET or HEAD'
,
async
()
=>
{
it
(
'should render 501 if the HTTP method is not GET or HEAD'
,
async
()
=>
{
const
url
=
`http://localhost:
${
appPort
}
/_next/abcdef`
const
url
=
`http://localhost:
${
appPort
}
/_next/abcdef`
const
methods
=
[
'POST'
,
'PUT'
,
'DELETE'
]
const
methods
=
[
'POST'
,
'PUT'
,
'DELETE'
]
...
...
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