problem description
how can I deny access to an interface other than login if it is known that the request does not contain session,?
the front-end framework uses Vue
the environmental background of the problems and what methods you have tried
the method I use is to clear a cookie field, and the front end determines that if it doesn"t have this field, it jumps to the login page, but the interface is actually accessible. How to control in the background that users cannot access interfaces other than login if they do not log in?
if (!requestData.SESSION().user) {
res.clearCookie("user", {"max-age":0});
res.setHeader("Set-Cookie", "user=true;path=/;max-age=0;");
// res.setHeader("Set-Cookie", "isVisit=true;path=/;max-age=0;");
// res.json({message: "please signin"})
}
related codes
/ / Please paste the code text below (do not replace the code with pictures)
what result do you expect? What is the error message actually seen?
1. How to control in the background that users cannot access interfaces other than login if they do not log in?
2. Another question is, how can you clear more than one Cookie at a time in the background?