Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Firebase Auth Failed on Netlify, But work on local server

When I deploy my site to netlify, I cannot sign in properly, new google window open and close automatically, my site Clock

function SignIn() {
const signInWithGoogle = () => {
  const provider = new firebase.auth.GoogleAuthProvider();
  auth.signInWithPopup(provider);
};

return (
  <>
    <button className="sign" onClick={signInWithGoogle}>
      Sign in with Google
    </button>
  </>
);

}

function SignOut() {
return (
  auth.currentUser && (
    <button className="sign" onClick={() => auth.signOut()}>
      Sign Out
    </button>
  )
);

}

Picture

It only happen in web after I deploy it on netlify, and works normally in local server

like image 667
Ricky Avatar asked Sep 01 '25 02:09

Ricky


1 Answers

Add your current netlify domain to firebase console

First go this url : https://console.firebase.google.com/u/0/project/your_project_name/authentication/providers

Then go to Authorised domains section and add https://kreivc-clock.netlify.app/

Always remember to check for auth errors and alert it :

const signIn = () => {
    auth
      .signInWithPopup(provider)
      .catch((error) => alert(error.message));
  };
like image 194
Gayatri Dipali Avatar answered Sep 02 '25 16:09

Gayatri Dipali