Next.js and reading from a local JSON file with fs
during build time:
Local (dev) | Local (prod) | Vercel (prod) | |
---|---|---|---|
getStaticProps | ✅ | ✅ | ✅ |
getServerSideProps | ✅ | ✅ | ❌ |
Using getServerSideProps and reading from a local JSON file with fs
on Vercel causes "500: Internal Server Error" for unknown reasons. To fix this, the JSON file needs to be imported as a module.