next auth vercel

Trying to deploy an app on vercel that use getServerSideProps, code seems to work fine on development but failing after deployment, doesn't seem to be finding the session

i tried setting all the required ENV varaibles, could anyone assist?!

export const getServerSideProps: GetServerSideProps<{ user: User }> = async (context) => {
  const session = await getServerAuthSession(context)

  if (!session) {
    return {
      redirect: {
        destination: '/?errorMessage=session',
        permanent: false,
      },
    }
  }

  const data = await prisma.orgUsers.findUnique({
    where: {
      orgId_userId: {
        orgId: context.params?.id as string,
        userId: session.user.id
      }
    }
  })

  if (!data || data.role != 'ADMIN') {
    return {
      redirect: {
        destination: '/?errorMessage=notAdmin',
        permanent: false,
      },
    }
  }

  return {
    props: {
      user: session.user
    },
  }
}
Was this page helpful?