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
5ce4f432
Commit
5ce4f432
authored
Jul 28, 2017
by
Arunoda Susiripala
Committed by
GitHub
Jul 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure the /static working properly. (#2675)
parent
23444fc7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
2 deletions
+22
-2
index.js
server/index.js
+10
-2
item.txt
test/integration/production/static/data/item.txt
+1
-0
index.test.js
test/integration/production/test/index.test.js
+11
-0
No files found.
server/index.js
View file @
5ce4f432
...
@@ -171,12 +171,20 @@ export default class Server {
...
@@ -171,12 +171,20 @@ export default class Server {
await
renderScript
(
req
,
res
,
page
,
this
.
renderOpts
)
await
renderScript
(
req
,
res
,
page
,
this
.
renderOpts
)
},
},
'/_next/:path?'
:
async
(
req
,
res
,
params
)
=>
{
// It's very important keep this route's param optional.
// (but it should support as many as params, seperated by '/')
// 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
)
=>
{
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
)
},
},
'/static/:path?'
:
async
(
req
,
res
,
params
)
=>
{
// It's very important keep this route's param optional.
// (but it should support as many as params, seperated by '/')
// 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
)
=>
{
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/static/data/item.txt
0 → 100644
View file @
5ce4f432
item
\ No newline at end of file
test/integration/production/test/index.test.js
View file @
5ce4f432
...
@@ -77,4 +77,15 @@ describe('Production Usage', () => {
...
@@ -77,4 +77,15 @@ describe('Production Usage', () => {
browser
.
close
()
browser
.
close
()
})
})
})
})
describe
(
'Misc'
,
()
=>
{
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/'
)
const
data
=
await
renderViaHTTP
(
appPort
,
'/static/data/item.txt'
)
expect
(
data
).
toBe
(
'item'
)
})
})
})
})
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