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
},
}
}
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
},
}
}
3 Replies
Jolt
Joltā€¢11mo ago
What's failing about it, any errors or something we could see for debug?
syrupking
syrupkingā€¢11mo ago
Can i DM you friend?
Jolt
Joltā€¢11mo ago
Sure šŸ‘