I am making a website with flask and react. The user inputs an email and password on a form, axios.post to the backend, backend checks if email and password is correct with database, if so, backend returns a cookie. In postman the cookie is set, not in my browser. Apparently the frontend is receiving nothing from the backend in my browser, because it doesnt even print the console.log that I put in the axios.post. In postman the cookie is set, not in my browser
Axios post:
const handleLogin = function(){
axios.post("http://127.0.0.1:5000/login", {email:email, password:password}, {withCredentials:true, headers : {'Content-Type' : 'multipart/form-data'}}).then(response => {
if(response.data["message"] == "Logado com sucesso"){
history.push('/');
}
}).catch(error => {alert(error.response.data); console.error("Error occurred in login request:", error);});
flask return:
if(check_password_hash(data[19],password)):
resposta = make_response(jsonify({"message": "Logado com sucesso"}))
resposta.set_cookie('id', str(data[0]), httponly=True, samesite='None')
return resposta
Apparently the frontend is receiving nothing from the backend in my browser, because it doesnt even print the console.log that I put in the axios.post. I set the CORS to support credentials and axios.post withCredentials:true.