Cookie not set when returning from OAuth callback

Hey! So I currently have a API route as the callback when the discord oauth has been completed and is callbacking to my website.. In there I make a JWT token that I want to set as a cookie, and that works. But the issue I am having is that when I redirect to the main page /.
setCookie(event, "jwt-token", token, {
httpOnly: true,
secure: true,
sameSite: "strict",
maxAge: timeBeforeExpiration,
});

res.writeHead(302, {
Location: `/`,
});
res.end();
setCookie(event, "jwt-token", token, {
httpOnly: true,
secure: true,
sameSite: "strict",
maxAge: timeBeforeExpiration,
});

res.writeHead(302, {
Location: `/`,
});
res.end();
So when I come back to the / page I need to refresh for the vue component to detect the cookie. I simply do:
const cookie = useCookie("jwt-token");
console.log("cookie: " + cookie.value);
const cookie = useCookie("jwt-token");
console.log("cookie: " + cookie.value);
And this returns undefined when I first get redirected from the callback. But gives me the cookie when I refresh? How can I fix this?
1 Reply
StilauGamer
StilauGamerOP7mo ago
🤔
Want results from more Discord servers?
Add your server