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
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.
Tokens are easily erased locally.
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
};
}
};
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](https://github.com/Azure/static-web-apps/assets/62348579/9b6f5510-c4e9-416e-a196-72f9d0adcc87)
Tokens are easily erased locally.![image](https://github.com/Azure/static-web-apps/assets/62348579/bc367adb-d9bf-48e1-ac2a-858f7c1d48ba)
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); }); };