Gokul Varadan
Gokul Varadan

Reputation: 11

Getting 500 | Internal Server Error when using getServerSideProps in NextJS after deploying in Vercel

I'm using server rendered pages in NextJS using getServerSideProps. It's in index.js (root page). When I'm making build locally, website working fine. But when i'm hosting this site in Vercel, it's showing 500 | Internal Server error.

export async function getServerSideProps(context) {
  let params = context.query;

  const job_col = await collection(db, "job_list");
  const job_snap = await getDocs(job_col);
  let jobData = job_snap.docs.map((doc) => ({
    ...doc.data(),
    id: doc.id,
  }));
  
  return {
    props: {
      jobs: jobData,
      params
    },
  };
}

Upvotes: 1

Views: 3589

Answers (2)

C H SANATH
C H SANATH

Reputation: 1

I had the same issue. But when I changed getserversideprops to getstaticprops it worked.

Upvotes: -2

Debotos Das
Debotos Das

Reputation: 569

It's because of the large payload. Move the large payload code portion to the client-side(useEffect) and it will be resolved.

Upvotes: -2

Related Questions