Skip to content

Commit

Permalink
Fix SPR header name (#9104)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer authored Oct 16, 2019
1 parent 42bf210 commit 393af8e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/next/build/webpack/loaders/next-serverless-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ const nextServerlessLoader: loader.Loader = function() {
: `const params = {};`
}
${
// Temporary work around -- `x-now-route-params` is a platform header
// Temporary work around: `x-now-route-matches` is a platform header
// _only_ set for `Prerender` requests. We should move this logic
// into our builder to ensure we're decoupled. However, this entails
// removing reliance on `req.url` and using `req.query` instead
// (which is needed for "custom routes" anyway).
isDynamicRoute(page)
? `const nowParams = req.headers && req.headers["x-now-route-params"]
? `const nowParams = req.headers && req.headers["x-now-route-matches"]
? getRouteMatcher(
(function() {
const { re, groups } = getRouteRegex("${page}");
Expand All @@ -160,7 +160,7 @@ const nextServerlessLoader: loader.Loader = function() {
groups
};
})()
)(req.headers["x-now-route-params"])
)(req.headers["x-now-route-matches"])
: null;
`
: `const nowParams = null;`
Expand Down
2 changes: 1 addition & 1 deletion test/integration/serverless/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ describe('Serverless', () => {
it('should have the correct query string for a spr route', async () => {
const paramRaw = 'test % 123'
const html = await fetchViaHTTP(appPort, `/dr/[slug]`, '', {
headers: { 'x-now-route-params': qs.stringify({ 1: paramRaw }) }
headers: { 'x-now-route-matches': qs.stringify({ 1: paramRaw }) }
}).then(res => res.text())
const $ = cheerio.load(html)
const data = JSON.parse($('#__NEXT_DATA__').html())
Expand Down

0 comments on commit 393af8e

Please sign in to comment.