dmitriy.dranko
01/31/2022, 2:32 PMawait supabase.auth.api.setAuthCookie(req, res)
, but when I sign out, I also try to do res.setHeader('Set-Cookie', 'sb:token=deleted; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT');
. This works locally, but when deployed to Vercel, the sb:token
persists on following requests and therefore I pass my middleware auth checks and access protected pages unintentionally.
FYI, doing the cookie management inside of a NextJS API. My NextJS FE calls my internal NextJS API during sign in/sign out to add/remove cookies respectively.
1) Does Supabase have a cleaner way of removing cookies?
2) If not, is there any idea of what is going wrong?
Thanks in advance. I love Supabase so far 🙂dmitriy.dranko
01/31/2022, 4:53 PMimport Cookies from 'cookies'
export default async function handler(req, res) {
if (req.method !== 'POST'){
return res.status(405).json({ status: 'fail', message: 'This method only supports POST' });
}
const cookies = new Cookies(req, res);
cookies.set('sb:token');
res.status(200);
}