Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SPR header name #9104

Merged
merged 1 commit into from Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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