Skip to content

Instantly share code, notes, and snippets.

@KolbySisk
Created July 19, 2022 16:24
Show Gist options
  • Save KolbySisk/592e04248d4ea45fc1e8632a8b49601d to your computer and use it in GitHub Desktop.
Save KolbySisk/592e04248d4ea45fc1e8632a8b49601d to your computer and use it in GitHub Desktop.
useEffect(() => {
const { data: authListener } = supabase.auth.onAuthStateChange(async (event, session) => {
await fetch('/api/set-auth-cookie', {
method: 'POST',
headers: new Headers({ 'content-Type': 'application/json' }),
body: JSON.stringify({ session, event }),
});
});
return () => {
authListener?.unsubscribe();
};
}, []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment