Mihai Andrei
12/20/2021, 9:26 AMZenon
12/20/2021, 12:33 PMjavascript
export default async function handler(req, res) {
const { username, email, password } = req.body;
let { user, error } = await supabase.auth.signUp({
email: email,
password: password,
});
if (!error) {
res.status(201).json({ data: user, message: "Signed Up!" });
}
}
I want the user I get from the signUp function to be stored in a cookie so that I can get the user from cookie in a different endpoint using
supabase.auth.api.getUserByCookie
Romain Petit
12/20/2021, 1:27 PMsupabase.auth.api.setAuthCookie(req)
Zenon
12/20/2021, 2:28 PMRomain Petit
12/20/2021, 2:30 PMevent: 'SIGNED_IN
in the request body and probably the user tooZenon
12/20/2021, 2:31 PMZenon
12/20/2021, 2:32 PMRomain Petit
12/20/2021, 2:34 PM{ event: 'SIGNED_IN', session: user }
Zenon
12/20/2021, 2:35 PMZenon
12/20/2021, 2:35 PMjavascript
let user = {
email: email,
password: password,
event: "SIGNED_IN",
};
Romain Petit
12/20/2021, 2:35 PMZenon
12/20/2021, 2:37 PMRomain Petit
12/20/2021, 2:38 PMexport default async function handler(req, res) {
const { username, email, password } = req.body;
let { user, error } = await supabase.auth.signUp({
email: email,
password: password,
});
if (!error) {
req.body.event = 'SIGNED_IN'
req.body.session = user;
await supabase.auth.api.setAuthCookie(req, res)
res.status(201).json({ data: user, message: "Signed Up!" });
}
}
Zenon
12/20/2021, 2:39 PMRomain Petit
12/20/2021, 2:39 PMZenon
12/20/2021, 2:42 PMRomain Petit
12/20/2021, 2:44 PMZenon
12/20/2021, 2:45 PMZenon
12/20/2021, 2:45 PMError [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
Zenon
12/20/2021, 2:45 PMRomain Petit
12/20/2021, 2:45 PMZenon
12/20/2021, 2:46 PMZenon
12/20/2021, 2:46 PMtdotflight22
12/20/2021, 6:37 PMkrithika
12/20/2021, 10:08 PMsignUp
instead. When signup is called, I'm getting no output in the console, and the page just reloads. Would you know what's causing that/how I could go about fixing/debugging this?krithika
12/20/2021, 10:38 PMconst {access_token, error} = await supabase.auth.signIn({username, password})
?Scott P
12/20/2021, 11:25 PMemail
, not username
krithika
12/20/2021, 11:50 PMScott P
12/20/2021, 11:52 PMsignIn({ username, password })
and the error is telling them to provide a valid email, so changing that to signIn({ email: username, password })
should fix itkrithika
12/20/2021, 11:57 PM