问题
I think i am making some kind of confusion here.
According to the documentation, if i want Server Side Rendering (SSR) for the page i export the async function:
getServerSideProps
But if i do that i can't build the project for running either locally or now Zeit now. If i try build or deploy i get:
Error for page /_error: pages with
getServerSideProps
can not be exported. See more info here: https://err.sh/next.js/gssp-export
The link provided by the error says i can't export. But I used the example from the documentation below:
import React from "react"
export async function getServerSideProps() {
return { props: { } }
}
function Page({ data }) {
// Render data...
}
export default Page
Do i have to change some configuration somewhere?
How to prevent from building this static page?
回答1:
Won´t work on page _error.js, by design decision, as posted here by nextjs maintenance staff.
One possibility is to use getInitialProps
, instead.
来源:https://stackoverflow.com/questions/61354282/pages-with-getserversideprops-can-not-be-exported