【发布时间】:2020-08-06 07:18:48
【问题描述】:
我一直在努力实施来自Next 9.3 的一些更新。我一直在从getInitialProps 移动到getServerSideProps 并注意到我的exportPathMap 对这些页面变得动态不满意。运行next 一切正常,但是当我运行next build && next export 时,我遇到了一些问题。
在static html export 的文档中,它声明If your pages don't have getInitialProps you may not need next export at all; next build is already enough thanks to Automatic Static Optimization. 当我运行next build && next start 时,我能够让它与我的新getServerSideProps 调用愉快地工作。我需要采取哪些步骤才能使其也可以与next export 一起使用,以便我可以通过 Netlify 进行部署。这是我尝试运行next export时遇到的错误示例
Error occurred prerendering page "/videos/[videos_title]". Read more: https://err.sh/next.js/prerender-error:
Error: Error for page /videos/[videos_title]: pages with `getServerSideProps` can not be exported. See more info here: https://err.sh/next.js/gssp-export
【问题讨论】:
-
在这里遇到同样的问题.. 你也可以在 nextjs github 页面本身中提出错误/请求吗?
-
我认为使用 getServerSideProps 时无法在 Netlify 上进行部署。
-
@Ganesh 我认为你是对的。您不能将 getServerSideProps 与下一次导出一起使用,因为下一次导出会将站点导出为静态站点。
-
我提供了部署 NextJS SSR 应用程序的方法。如果有帮助,请结帐并接受,以便其他人可以使用它。
标签: next.js netlify static-site