Azure / Azure/static-web-apps

Logout token does not disappear

Open
#1,479 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

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);
});
};

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.