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
10241fe6
Commit
10241fe6
authored
Jul 26, 2017
by
Arunoda Susiripala
Committed by
GitHub
Jul 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the route redirect error when we've multiple path params. (#2652)
For an example, with a URL like: /static/data/hello.txt
parent
84de7f93
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
2 deletions
+7
-2
index.js
server/index.js
+4
-2
item.txt
test/integration/production/static/data/item.txt
+1
-0
index.test.js
test/integration/production/test/index.test.js
+2
-0
No files found.
server/index.js
View file @
10241fe6
...
@@ -200,17 +200,19 @@ export default class Server {
...
@@ -200,17 +200,19 @@ export default class Server {
},
},
// It's very important keep this route's param optional.
// 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.
// Othewise this will lead to a pretty simple DOS attack.
// See more: https://github.com/zeit/next.js/issues/2617
// 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.
// 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.
// Othewise this will lead to a pretty simple DOS attack.
// See more: https://github.com/zeit/next.js/issues/2617
// 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/static/data/item.txt
0 → 100644
View file @
10241fe6
item
\ No newline at end of file
test/integration/production/test/index.test.js
View file @
10241fe6
...
@@ -107,6 +107,8 @@ describe('Production Usage', () => {
...
@@ -107,6 +107,8 @@ describe('Production Usage', () => {
// See: https://github.com/zeit/next.js/issues/2617
// See: https://github.com/zeit/next.js/issues/2617
await
renderViaHTTP
(
appPort
,
'/_next/'
)
await
renderViaHTTP
(
appPort
,
'/_next/'
)
await
renderViaHTTP
(
appPort
,
'/static/'
)
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