I'm currently working on a personal project and I'm stuck at the moment with the login page. I mention that I use Firebase Cloud functions and axios to post / get requests.
So, this is the cloud function for the login:
app.post('/login', (req,res) => {
    const user = {
        email: req.body.email,
        password: req.body.password,
    };
    let errors = {};
    if(isEmpty(user.email)) errors.email = 'Must not be empty !';
    if(isEmpty(user.password)) errors.email = 'Must not be empty !';
    
    if(Object.keys(errors).length > 0) return res.status(400).json(errors);
    firebase.auth().signInWithEmailAndPassword(user.email,user.password)
            .then(() => {
                return res.json(user.email);
            })
            .catch(err => {
                console.error(err);
                res.status(500).json({error: err.code});
            })
})
which works fine since I could send data via Postman.
There is the code from the Login.js :
    const [email,setEmail] = useState("");
    const [password,setPassword] = useState("");
    const handleSubmit = (e) => {
        e.preventDefault();
        axios
            .post('/login', {
                email: email,
                password: password,
            })
            .then((res) => {
                console.log(res.data);
                this.props.history.push('/');
            })
            .catch((err) => {
                console.log(err);
            })
    }
And this is the form:
<input value={email} onChange={(e) => setEmail(e.target.value)} id="email" name="password" className="login__input" type="email" placeholder="Email"/>
<input value={password} onChange={(e) => setPassword(e.target.value)} id="password" name="password" className="login__input" type="password" placeholder="Password"/>
<button onClick={handleSubmit} className="login__button" type="submit">Connect</button
And I also added the proxy in the package.json:
"proxy" : "http://localhost:5000/XXXXXXXXXX/europe-west1/api"
In this state, I get a 500 Internal server error status. I tried many different options, that give me Access-Control-Allow-origin error even though I tried to fix it, it seems that it doesn't work either way.
EDIT:
console:
> functions: Beginning execution of "api"
> >  [t [Error]: The email address is badly formatted.] {
> >    code: 'auth/invalid-email',
> >    a: null
> >  } i  functions: Finished "api" in ~1s i  functions: Beginning execution of "api" i  functions: Finished "api" in ~1s i  functions:
> Beginning execution of "api"
> >  [t [Error]: The password is invalid or the user does not have a password.] {
> >    code: 'auth/wrong-password',
> >    a: null
> >  } i  functions: Finished "api" in ~1s i  functions: Beginning execution of "api"
> >  [t [Error]: The password is invalid or the user does not have a password.] {
> >    code: 'auth/wrong-password',
> >    a: null
> >  } i  functions: Finished "api" in ~1s i  functions: Beginning execution of "api"
> >  [t [Error]: The password is invalid or the user does not have a password.] {
> >    code: 'auth/wrong-password',
> >    a: null
> >  } i  functions: Finished "api" in ~1s i  functions: Beginning execution of "api" i  functions: Finished "api" in ~1s
Thank you.
