サーバー側にリクエストを投げた結果を受けて表示したい。
import Link from "next/link"; export default function IndexPage({ param }) { return ( <div> Hello {param.Hello}.{" "} <Link href="/about"> <a>About</a> </Link> </div> ); } export async function getServerSideProps() { const res = await fetch(`http://localhost:1325/api/echo`); const data = await res.json(); return { props: { param: data } }; }
エクスポートしたい。
$ npx next export Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error Error: Error for page /: pages with `getServerSideProps` can not be exported. See more info here: https://nextjs.org/docs/messages/gssp-export
The
getServerSideProps
lifecycle is not compatible withnext export
, so you'll need to usenext start
or a serverless deployment.
ダメなんか・・・。node.js でサーバー動かせばいいんだけど諸事情にやりづらい環境なので辛い。
windows service で動かす方法があったのでメモ。