Having trouble testing my app on a mobile device because it is not receiving cookies from server-side requests. (works fine in Chrome)
In the Next.js getServerSideProps
function, I have the following code:
export async function getServerSideProps({ req }) {
const { user } = await supabase.auth.api.getUserByCookie(req)
console.log('user from cookie', user)
if (!user) {
return { props: {}, redirect: { destination: '/sign-in' } }
}
const { data: teams } = await supabase
.from('teams')
.select('*')
.eq('user_id', user.id)
// handle user data...
return {
props: {
teams,
},
}
}
This code returns a user
object when tested on Chrome or any other web browser, but fails to do so on mobile devices where it returns user = null.
I suspect the issue lies with the cookie session handling. Any advice on how to resolve this would be greatly appreciated.