pheralb
03/14/2022, 2:21 PMts
const handleLogin = async () => {
const { error } = await supabase.auth.signIn({provider: "github"});
if (error) {
alert(JSON.stringify(error));
}
};
and I get the user. But when I access a path protected with getServerSideProps: ts
export const getServerSideProps: GetServerSideProps = async ({ req }) => {
const { user } = await supabase.auth.api.getUserByCookie(req);
if (!user) {
return { props: {}, redirect: { destination: "/" } };
}
return { props: { user } };
};
the user is always null. My "pages/api/auth.ts": ts
export default function handler(req: NextApiRequest, res: NextApiResponse) {
supabase.auth.api.setAuthCookie(req, res)
}
. Does anyone know how to get user once logged into the protected page? 🤔silentworks
03/14/2022, 2:46 PM@supabase/supabase-auth-helpers
to get this feature out of the box. https://github.com/supabase-community/supabase-auth-helperspheralb
03/14/2022, 3:16 PM