'How do I resolve "Firebase: Error (auth/network-request-failed)." in a react cordova app?
I am working on a react cordova app, and I'm trying to authenticate my users with Firebase createUserWithEmailAndPassword. The problem however is it always return this "Firebase: Error (auth/network-request-failed)." anytime I click the sign up button. I have enabled Email/Password as one of my sign in methods in my firebase console, and I have tried both the older version of firebase and the newest version 9 Modular SDK version, I have also ensured that my sign in button is not of type submit and also prevented event default in my button function. All these are answers that people have given to this question but none of these has helped me so far.
import { getAuth, createUserWithEmailAndPassword } from "firebase/auth";
const signInWithEmail = (setAlertState, setAlertMessage) => {
const auth = getAuth();
createUserWithEmailAndPassword(auth, document.getElementById("email-input"), document.getElementById("password-input")).then((userCredential) => {
const user = userCredential.user;
setAlertState(true);
setAlertMessage(user.uid);
}).catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
setAlertState(true);
setAlertMessage(errorCode);
});
}
export default signInWithEmail;
<Button
color="primary"
variant="contained"
type="input"
onClick={(event) => {
event.preventDefault();
signInWithEmail(setAlertState, setAlertMessage);
}}
sx={{
position:"relative",
marginTop:"1.5rem",
width:"100%",
height:"3rem",
borderRadius:"1rem",
color:"custom.main",
}}
>
Sign In
</Button>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
