I try to connect my local backend with the fronte
axios({
method: "post",
url: "http://localhost:5000/api/user/login",
withCredentials: true,
data: {
email,
password,
},
})
.then((res) => {
if (res.data.errors) {
emailError.innerHTML = res.data.errors.email;
passwordError.innerHTML = res.data.errors.password;
} else {
window.location = "/";
}
})
.catch((err) => {
console.log(err);
});
};
nd Reactjs. The backend works very well with the postman but when I just try to login from my front end, in the console.log I get the error message 'problem with cors'... What am I missing? and here is the error message : Access to XMLHttpRequest at 'http://localhost:5000/api/user/login' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
here is the code of the function that runs after the submit