Unverified Commit 393af8e6 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Fix SPR header name (#9104)

parent 42bf2109
...@@ -133,13 +133,13 @@ const nextServerlessLoader: loader.Loader = function() { ...@@ -133,13 +133,13 @@ const nextServerlessLoader: loader.Loader = function() {
: `const params = {};` : `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 // _only_ set for `Prerender` requests. We should move this logic
// into our builder to ensure we're decoupled. However, this entails // into our builder to ensure we're decoupled. However, this entails
// removing reliance on `req.url` and using `req.query` instead // removing reliance on `req.url` and using `req.query` instead
// (which is needed for "custom routes" anyway). // (which is needed for "custom routes" anyway).
isDynamicRoute(page) isDynamicRoute(page)
? `const nowParams = req.headers && req.headers["x-now-route-params"] ? `const nowParams = req.headers && req.headers["x-now-route-matches"]
? getRouteMatcher( ? getRouteMatcher(
(function() { (function() {
const { re, groups } = getRouteRegex("${page}"); const { re, groups } = getRouteRegex("${page}");
...@@ -160,7 +160,7 @@ const nextServerlessLoader: loader.Loader = function() { ...@@ -160,7 +160,7 @@ const nextServerlessLoader: loader.Loader = function() {
groups groups
}; };
})() })()
)(req.headers["x-now-route-params"]) )(req.headers["x-now-route-matches"])
: null; : null;
` `
: `const nowParams = null;` : `const nowParams = null;`
......
...@@ -207,7 +207,7 @@ describe('Serverless', () => { ...@@ -207,7 +207,7 @@ describe('Serverless', () => {
it('should have the correct query string for a spr route', async () => { it('should have the correct query string for a spr route', async () => {
const paramRaw = 'test % 123' const paramRaw = 'test % 123'
const html = await fetchViaHTTP(appPort, `/dr/[slug]`, '', { 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()) }).then(res => res.text())
const $ = cheerio.load(html) const $ = cheerio.load(html)
const data = JSON.parse($('#__NEXT_DATA__').html()) const data = JSON.parse($('#__NEXT_DATA__').html())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment