From 7269572f854ecb6ad7301293bc5037784a73c4de Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Wed, 16 Oct 2019 14:41:22 -0400 Subject: [PATCH] Fix SPR header name --- .../next/build/webpack/loaders/next-serverless-loader.ts | 6 +++--- test/integration/serverless/test/index.test.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/next/build/webpack/loaders/next-serverless-loader.ts b/packages/next/build/webpack/loaders/next-serverless-loader.ts index e21329d52f1d..617f9113e338 100644 --- a/packages/next/build/webpack/loaders/next-serverless-loader.ts +++ b/packages/next/build/webpack/loaders/next-serverless-loader.ts @@ -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}"); @@ -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;` diff --git a/test/integration/serverless/test/index.test.js b/test/integration/serverless/test/index.test.js index cf30d8e2b7d3..8b1db591d459 100644 --- a/test/integration/serverless/test/index.test.js +++ b/test/integration/serverless/test/index.test.js @@ -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())