Commit 147a5ce6 authored by Arunoda Susiripala's avatar Arunoda Susiripala

Fix server rendering issue for normal apps.

parent 42f1d2ef
...@@ -133,6 +133,7 @@ export default class Link extends Component { ...@@ -133,6 +133,7 @@ export default class Link extends Component {
// "<page>/index.html" directly. // "<page>/index.html" directly.
const endsWithSlash = /\/$/.test(props.href) const endsWithSlash = /\/$/.test(props.href)
if ( if (
typeof __NEXT_DATA__ !== 'undefined' &&
__NEXT_DATA__.nextExport && __NEXT_DATA__.nextExport &&
!endsWithSlash !endsWithSlash
) { ) {
......
...@@ -49,6 +49,13 @@ async function doRender (req, res, pathname, query, { ...@@ -49,6 +49,13 @@ async function doRender (req, res, pathname, query, {
const dist = getConfig(dir).distDir 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([ let [Component, Document] = await Promise.all([
requireModule(join(dir, dist, 'dist', 'pages', page)), requireModule(join(dir, dist, 'dist', 'pages', page)),
requireModule(join(dir, dist, 'dist', 'pages', '_document')) requireModule(join(dir, dist, 'dist', 'pages', '_document'))
...@@ -91,13 +98,6 @@ async function doRender (req, res, pathname, query, { ...@@ -91,13 +98,6 @@ async function doRender (req, res, pathname, query, {
if (res.finished) return 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, { const doc = createElement(Document, {
__NEXT_DATA__: { __NEXT_DATA__: {
props, props,
......
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