File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
packages/next/build/webpack/loaders
test/integration/prerender/test Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -216,13 +216,14 @@ const nextServerlessLoader: loader.Loader = function() {
216
216
}
217
217
let _nextData = false
218
218
219
- if (req.url.match(/_next\\/data/)) {
219
+ const parsedUrl = handleRewrites(parse(req.url, true))
220
+
221
+ if (parsedUrl.pathname.match(/_next\\/data/)) {
220
222
_nextData = true
221
- req.url = req.url
223
+ parsedUrl.pathname = parsedUrl.pathname
222
224
.replace(new RegExp('/_next/data/${ escapedBuildId } /'), '/')
223
225
.replace(/\\.json$/, '')
224
226
}
225
- const parsedUrl = handleRewrites(parse(req.url, true))
226
227
227
228
const renderOpts = Object.assign(
228
229
{
Original file line number Diff line number Diff line change @@ -265,6 +265,16 @@ const runTests = (dev = false) => {
265
265
expect ( JSON . parse ( params ) ) . toEqual ( { } )
266
266
} )
267
267
268
+ it ( 'should not supply query values to params in /_next/data request' , async ( ) => {
269
+ const data = JSON . parse (
270
+ await renderViaHTTP (
271
+ appPort ,
272
+ `/_next/data/${ buildId } /something.json?hello=world`
273
+ )
274
+ )
275
+ expect ( data . pageProps . params ) . toEqual ( { } )
276
+ } )
277
+
268
278
it ( 'should not supply query values to params or useRouter dynamic page SSR' , async ( ) => {
269
279
const html = await renderViaHTTP ( appPort , '/blog/post-1?hello=world' )
270
280
const $ = cheerio . load ( html )
@@ -580,7 +590,7 @@ describe('SPR Prerender', () => {
580
590
await nextBuild ( appDir )
581
591
stderr = ''
582
592
appPort = await findPort ( )
583
- app = nextStart ( appDir , appPort , {
593
+ app = await nextStart ( appDir , appPort , {
584
594
onStderr : msg => {
585
595
stderr += msg
586
596
} ,
You can’t perform that action at this time.
0 commit comments