mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Fix server rendering issue for normal apps.
This commit is contained in:
parent
42f1d2efda
commit
147a5ce641
|
@ -133,6 +133,7 @@ export default class Link extends Component {
|
|||
// "<page>/index.html" directly.
|
||||
const endsWithSlash = /\/$/.test(props.href)
|
||||
if (
|
||||
typeof __NEXT_DATA__ !== 'undefined' &&
|
||||
__NEXT_DATA__.nextExport &&
|
||||
!endsWithSlash
|
||||
) {
|
||||
|
|
|
@ -49,6 +49,13 @@ async function doRender (req, res, pathname, query, {
|
|||
|
||||
const dist = getConfig(dir).distDir
|
||||
|
||||
// realPathname is pretty useful in the document.js
|
||||
// In there, we include a proper valid resolved path.
|
||||
// That helps us to server that JSON page directly from a static server.
|
||||
// Basically, this is a requirment for next-export
|
||||
const pageRealPath = await resolvePath(join(dir, dist, 'dist', 'pages', page))
|
||||
const realPathname = pageRealPath.replace(join(dir, dist, 'dist', 'pages'), '')
|
||||
|
||||
let [Component, Document] = await Promise.all([
|
||||
requireModule(join(dir, dist, 'dist', 'pages', page)),
|
||||
requireModule(join(dir, dist, 'dist', 'pages', '_document'))
|
||||
|
@ -91,13 +98,6 @@ async function doRender (req, res, pathname, query, {
|
|||
|
||||
if (res.finished) return
|
||||
|
||||
// realPathname is pretty useful in the document.js
|
||||
// In there, we include a proper valid resolved path.
|
||||
// That helps us to server that JSON page directly from a static server.
|
||||
// Basically, this is a requirment for next-export
|
||||
const pageRealPath = await resolvePath(join(dir, 'pages', pathname))
|
||||
const realPathname = pageRealPath.replace(join(dir, 'pages'), '')
|
||||
|
||||
const doc = createElement(Document, {
|
||||
__NEXT_DATA__: {
|
||||
props,
|
||||
|
|
Loading…
Reference in a new issue