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
vae
vae16mo ago
What's failing about it, any errors or something we could see for debug?
troy
troy16mo ago
Can i DM you friend?
vae
vae16mo ago
Sure 👍
Want results from more Discord servers?
Add your server