This block executes when I submit the login form, if all is ok (status 200) it should push the navigation to "/mi-cuenta" page, this works fine in local but no in production, I have no evident bug or error thrown. I'm using auth and middleware to protect specific paths.
handle submit code:
const handleSubmit = async (e) => {
e.preventDefault();
try {
const response = await axios.post("/api/auth/login", credentials);
if (response.status === 200) {
/* document.getElementById("logoClick").click(); */
router.replace("/mi-cuenta");
handleLogin("popup");
}
const response2 = await axios.get("/api/profile");
if (response2.status === 200) {
setIsLogged(true);
const roles = response2.data.roles;
for (let role of roles) {
if (role.name === "admin") {
setIsAdmin(true);
}
}
}
} catch (error) {
setIsAdmin(false);
setIsLogged(false);
setShowAlert(true);
console.log("Error: ", error);
}
};