Pages with `getServerSideProps` can not be exported

本秂侑毒 提交于 2020-06-26 08:28:08

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!