Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
318 stars 53 forks source link

Logout token does not disappear #1479

Open ninggoo opened 1 month ago

ninggoo commented 1 month ago

I use an Azure static web app, but there is a problem where the token is not deleted even if I log out. I've been struggling with this problem for several days. please help me.

In the Azure Statcic web app, the token is not deleted even if I log out. image

Tokens are easily erased locally. image

Below is the Azure Function app code for Logout. module.exports = async function (context, req) { if (req.cookies && req.cookies.token) { context.res = { status: 200, cookies: [{ name: "token", value: "", path: "/",
httpOnly: true, expires: new Date(0), sameSite: "None", secure: true }] }; } else { context.res = { status: 200 }; } };

Below is the Azure static web app client code for Logout. const logout = () => { axios.delete("/api/accountDelete", { withCredentials: true }).then(() => { alert("You have logged out.") state.account.id = null; state.account.name = ""; localStorage.removeItem('account'); //추가 Cookies.remove('token', { path: '/', sameSite: 'None', secure: true }); }).catch((error) => { console.error("Logout failed: ", error); }); };