StilauGamer
StilauGamer
Explore posts from servers
NNuxt
Created by StilauGamer on 5/14/2024 in #❓・help
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?
2 replies
NNuxt
Created by StilauGamer on 5/10/2024 in #❓・help
Localstorage + JWT
Hello! So I am currently working on a project where I want to store a JWT Token in localstorage... But I am having some issues finding out how I can use it? Is there a better way than storing it in the localstorage, and how would I store it in the localstorage?
15 replies