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
2ff2e9e1
Commit
2ff2e9e1
authored
Jan 25, 2020
by
JJ Kasper
Committed by
Joe Haddad
Jan 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update _next/data URL handling in serverless-loader (#10261)
Co-authored-by:
Joe Haddad
<
timer150@gmail.com
>
parent
f143ca63
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
next-serverless-loader.ts
...ages/next/build/webpack/loaders/next-serverless-loader.ts
+4
-3
index.test.js
test/integration/prerender/test/index.test.js
+11
-1
No files found.
packages/next/build/webpack/loaders/next-serverless-loader.ts
View file @
2ff2e9e1
...
@@ -216,13 +216,14 @@ const nextServerlessLoader: loader.Loader = function() {
...
@@ -216,13 +216,14 @@ const nextServerlessLoader: loader.Loader = function() {
}
}
let _nextData = false
let _nextData = false
if (req.url.match(/_next\\/data/)) {
const parsedUrl = handleRewrites(parse(req.url, true))
if (parsedUrl.pathname.match(/_next\\/data/)) {
_nextData = true
_nextData = true
req.url = req.url
parsedUrl.pathname = parsedUrl.pathname
.replace(new RegExp('/_next/data/
${
escapedBuildId
}
/'), '/')
.replace(new RegExp('/_next/data/
${
escapedBuildId
}
/'), '/')
.replace(/\\.json$/, '')
.replace(/\\.json$/, '')
}
}
const parsedUrl = handleRewrites(parse(req.url, true))
const renderOpts = Object.assign(
const renderOpts = Object.assign(
{
{
...
...
test/integration/prerender/test/index.test.js
View file @
2ff2e9e1
...
@@ -265,6 +265,16 @@ const runTests = (dev = false) => {
...
@@ -265,6 +265,16 @@ const runTests = (dev = false) => {
expect
(
JSON
.
parse
(
params
)).
toEqual
({})
expect
(
JSON
.
parse
(
params
)).
toEqual
({})
})
})
it
(
'should not supply query values to params in /_next/data request'
,
async
()
=>
{
const
data
=
JSON
.
parse
(
await
renderViaHTTP
(
appPort
,
`/_next/data/
${
buildId
}
/something.json?hello=world`
)
)
expect
(
data
.
pageProps
.
params
).
toEqual
({})
})
it
(
'should not supply query values to params or useRouter dynamic page SSR'
,
async
()
=>
{
it
(
'should not supply query values to params or useRouter dynamic page SSR'
,
async
()
=>
{
const
html
=
await
renderViaHTTP
(
appPort
,
'/blog/post-1?hello=world'
)
const
html
=
await
renderViaHTTP
(
appPort
,
'/blog/post-1?hello=world'
)
const
$
=
cheerio
.
load
(
html
)
const
$
=
cheerio
.
load
(
html
)
...
@@ -580,7 +590,7 @@ describe('SPR Prerender', () => {
...
@@ -580,7 +590,7 @@ describe('SPR Prerender', () => {
await
nextBuild
(
appDir
)
await
nextBuild
(
appDir
)
stderr
=
''
stderr
=
''
appPort
=
await
findPort
()
appPort
=
await
findPort
()
app
=
nextStart
(
appDir
,
appPort
,
{
app
=
await
nextStart
(
appDir
,
appPort
,
{
onStderr
:
msg
=>
{
onStderr
:
msg
=>
{
stderr
+=
msg
stderr
+=
msg
},
},
...
...
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