stibbs
07/29/2021, 8:28 AMsilentworks
07/29/2021, 9:16 AMstibbs
07/29/2021, 10:12 AMMihai Andrei
07/29/2021, 10:42 AMstibbs
07/29/2021, 10:49 AMSduu_
07/29/2021, 10:54 AMMihai Andrei
07/29/2021, 11:00 AMSduu_
07/29/2021, 11:03 AMMihai Andrei
07/29/2021, 11:05 AMMihai Andrei
07/29/2021, 11:06 AMSduu_
07/29/2021, 11:08 AMMihai Andrei
07/29/2021, 11:09 AMSduu_
07/29/2021, 11:11 AMMihai Andrei
07/29/2021, 11:12 AMSduu_
07/29/2021, 11:13 AMMihai Andrei
07/29/2021, 11:15 AMSduu_
07/29/2021, 11:17 AMSduu_
07/29/2021, 11:18 AMMihai Andrei
07/29/2021, 11:19 AMsilentworks
07/29/2021, 11:37 AMstibbs
07/29/2021, 12:57 PMimport supabase from '@utils/supabase';
const AuthCookie = async (req, res) => {
supabase.auth.api.setAuthCookie(req, res);
};
export default AuthCookie;
Updated my auth hook to include:
----other stuff
async function handleAuthChange(event, session) {
await fetch('/api/auth', {
method: 'POST',
headers: new Headers({ 'Content-Type': 'application/json' }),
credentials: 'same-origin',
body: JSON.stringify({ event, session })
});
}
----within context provider
const { data: authListener } = supabase.auth.onAuthStateChange(
async (event, session) => {
setSession(session);
handleAuthChange(event, session); <---- this
setUser(session?.user ?? false);
}
);
Then on my /api/settings I can call supabase.auth.setAuth(req.cookies['sb:token']);
which passes the user details back to the server 🙂
Can the setAuth call go in the auth hook somewhere? 🤔burggraf
07/29/2021, 12:58 PMa d
07/29/2021, 3:23 PMfrubalu
07/29/2021, 3:24 PMa d
07/29/2021, 3:24 PMfrubalu
07/29/2021, 3:25 PMa d
07/29/2021, 3:25 PMamserra
07/29/2021, 3:27 PMScott P
07/29/2021, 3:28 PM/rest/
endpoint, and instead invokes it from a different API entirely.
If you need something like this, consider creating a Postgres function and invoking via .rpc()
.a d
07/29/2021, 3:30 PM