NextJS 502 Bad gateaway

Hello, I’ve got this error after trying to move my blog project to production mode in NextJS, on the index page, I’m getting info from api (currently just test message) and displaying it on index page.
Somewhy when running in development mode (yarn dev), everything works normally, but when I run project in production mode, request gives out a Cloudflare error message, saying that there’s a 502 Bad gateaway error at (/api/posts).
When visiting the api endpoint myself, everything works normally, tried clearing cache locally in the project and Cloudflare cache but no result.

Website: https://zeronet.space/
API endpoint: https://zeronet.space/api/posts (works normally if visiting yourself)

NodeJS: v16.14.0

NextJS: 12.1.0
React: 17.0.2

(Will update the details if needed)

Bump.

Problem was solved by myself, getStaticProps isn’t compatible with Cloudflare, it will generate page if its accessible, but it wont check the status code.
Solution: use getServerSideProps