I'm running supabase-auth-helpers-react on next.js and we have a login page that emails the user a magic link. Upon authorization when the link is clicked, the user should be redirected to the '/profile' page using: supabase.auth.signIn( { email: data.email }, { redirectTo:
${process.env.NEXT_PUBLIC_HOST_DOMAIN}/profile
${process.env.NEXT_PUBLIC_HOST_DOMAIN}/profile
} )
When the profile page is fetching the user data client side by hitting an api endpoint within the app, the redirect works accordingly. const { user, error } = useUser() useEffect(() => { async function loadData() { fetch(
/api/users/${user?.id}
/api/users/${user?.id}
) .then(res => res.json()) .then(result => setInfo(result)) } // Only run query once user is logged in. if (user) { try { loadData() console.log(user) } catch (error) { console.log(error) } } }, [user])
When fetching the data using getServerSideProps, the redirect no longer works and i get sent to the home route of the app. The user is confirmed to be authorized and signed in when navigating back to the /profile page.
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.