Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
c77338bd
Unverified
Commit
c77338bd
authored
Oct 15, 2019
by
Joe Haddad
Committed by
GitHub
Oct 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Temporary: Add Support for Now Platform Headers (#9085)
parent
8676b0ff
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
1 deletion
+11
-1
next-serverless-loader.ts
...ages/next/build/webpack/loaders/next-serverless-loader.ts
+11
-1
No files found.
packages/next/build/webpack/loaders/next-serverless-loader.ts
View file @
c77338bd
...
@@ -131,7 +131,17 @@ const nextServerlessLoader: loader.Loader = function() {
...
@@ -131,7 +131,17 @@ const nextServerlessLoader: loader.Loader = function() {
?
`const params = fromExport && !unstable_getStaticProps ? {} : getRouteMatcher(getRouteRegex("
${
page
}
"))(parsedUrl.pathname) || {};`
?
`const params = fromExport && !unstable_getStaticProps ? {} : getRouteMatcher(getRouteRegex("
${
page
}
"))(parsedUrl.pathname) || {};`
:
`const params = {};`
:
`const params = {};`
}
}
const result = await renderToHTML(req, res, "
${
page
}
", Object.assign({}, unstable_getStaticProps ? {} : parsedUrl.query, params, sprData ? { _nextSprData: '1' } : {}), renderOpts)
${
// Temporary work around -- `x-now-route-params` 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"]) ? querystring.parse(req.headers["x-now-route-params"]) : null;`
:
`const nowParams = null;`
}
const result = await renderToHTML(req, res, "
${
page
}
", Object.assign({}, unstable_getStaticProps ? {} : parsedUrl.query, nowParams ? nowParams : params, sprData ? { _nextSprData: '1' } : {}), renderOpts)
if (fromExport) return { html: result, renderOpts }
if (fromExport) return { html: result, renderOpts }
return result
return result
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment