Unverified Commit 235b3bef authored by Fabio Benedetti's avatar Fabio Benedetti Committed by GitHub

fix(client-routing): page render (#13305)

Fixes https://github.com/zeit/next.js/issues/12935
parent 7bd52b8d
......@@ -290,7 +290,8 @@ const nextServerlessLoader: loader.Loader = function () {
{
Component,
pageConfig: config,
nextExport: fromExport
nextExport: fromExport,
isDataReq: _nextData,
},
options,
)
......
......@@ -1049,6 +1049,7 @@ export default class Server {
const renderOpts: RenderOpts = {
...components,
...opts,
isDataReq,
}
renderResult = await renderToHTML(req, res, pathname, query, renderOpts)
......
......@@ -666,7 +666,7 @@ export async function renderToHTML(
// We only need to do this if we want to support calling
// _app's getInitialProps for getServerSideProps if not this can be removed
if (isDataReq) return props
if (isDataReq && !isSSG) return props
// We don't call getStaticProps or getServerSideProps while generating
// the fallback so make sure to set pageProps to an empty object
......
import Link from 'next/link'
export async function getServerSideProps() {
export async function getServerSideProps({ req }) {
return {
props: {
url: req.url,
world: 'world',
time: new Date().getTime(),
},
}
}
const Page = ({ world, time }) => {
const Page = ({ world, time, url }) => {
if (typeof window === 'undefined') {
if (url.startsWith('/_next/data/')) {
throw new Error('invalid render for data request')
}
}
return (
<>
<p>hello {world}</p>
......
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