In my case, i was getting server session at static page, which was unavailable at build time, and throwing 501 error in production but runs locally. Thank you