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
564dbdd2
Commit
564dbdd2
authored
Jul 24, 2017
by
Arunoda Susiripala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test case to prevent issue #2617 to happen again.
parent
c3fd0ed5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
index.js
server/index.js
+6
-0
index.test.js
test/integration/production/test/index.test.js
+7
-0
No files found.
server/index.js
View file @
564dbdd2
...
@@ -199,11 +199,17 @@ export default class Server {
...
@@ -199,11 +199,17 @@ export default class Server {
await
renderScript
(
req
,
res
,
page
,
this
.
renderOpts
)
await
renderScript
(
req
,
res
,
page
,
this
.
renderOpts
)
},
},
// It's very important keep this route's param optional.
// Othewise this will lead to a pretty simple DOS attack.
// See more: https://github.com/zeit/next.js/issues/2617
'/_next/:path?'
:
async
(
req
,
res
,
params
)
=>
{
'/_next/:path?'
:
async
(
req
,
res
,
params
)
=>
{
const
p
=
join
(
__dirname
,
'..'
,
'client'
,
...(
params
.
path
||
[]))
const
p
=
join
(
__dirname
,
'..'
,
'client'
,
...(
params
.
path
||
[]))
await
this
.
serveStatic
(
req
,
res
,
p
)
await
this
.
serveStatic
(
req
,
res
,
p
)
},
},
// It's very important keep this route's param optional.
// Othewise this will lead to a pretty simple DOS attack.
// See more: https://github.com/zeit/next.js/issues/2617
'/static/:path?'
:
async
(
req
,
res
,
params
)
=>
{
'/static/:path?'
:
async
(
req
,
res
,
params
)
=>
{
const
p
=
join
(
this
.
dir
,
'static'
,
...(
params
.
path
||
[]))
const
p
=
join
(
this
.
dir
,
'static'
,
...(
params
.
path
||
[]))
await
this
.
serveStatic
(
req
,
res
,
p
)
await
this
.
serveStatic
(
req
,
res
,
p
)
...
...
test/integration/production/test/index.test.js
View file @
564dbdd2
...
@@ -101,6 +101,13 @@ describe('Production Usage', () => {
...
@@ -101,6 +101,13 @@ describe('Production Usage', () => {
const
html
=
await
app
.
renderToHTML
({},
res
,
'/finish-response'
,
{})
const
html
=
await
app
.
renderToHTML
({},
res
,
'/finish-response'
,
{})
expect
(
html
).
toBeFalsy
()
expect
(
html
).
toBeFalsy
()
})
})
it
(
'should allow to access /static/ and /_next/'
,
async
()
=>
{
// This is a test case which prevent the following issue happening again.
// See: https://github.com/zeit/next.js/issues/2617
await
renderViaHTTP
(
appPort
,
'/_next/'
)
await
renderViaHTTP
(
appPort
,
'/static/'
)
})
})
})
describe
(
'X-Powered-By header'
,
()
=>
{
describe
(
'X-Powered-By header'
,
()
=>
{
...
...
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