未验证 提交 393af8e6 编写于 作者: J Joe Haddad 提交者: GitHub

Fix SPR header name (#9104)

上级 42bf2109
......@@ -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;`
......
......@@ -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())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册