mercredi 4 juillet 2018

create users on firebase using its authenticate methods

i tried sending the credentials and this error appears. Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key=*******. (Reason: CORS request did not succeed).

    (function () {

  var config = {
    apiKey: "*******",
    authDomain: "*******",
    databaseURL: "*******",
    projectId: "*******",
    storageBucket: "*******",
    messagingSenderId: "*******"
  };
  firebase.initializeApp(config);

  const email = document.getElementById('email');
  const password = document.getElementById('password');
  const btnSignUp = document.getElementById('btnSignUp');

  btnSignUp.addEventListener('click', e => {
    const mail = email.value;
    const pass = password.value;

    firebase.auth().createUserWithEmailAndPassword(mail, pass).catch(function(error) {

      var errorCode = error.code;
      var errorMessage = error.message;

      if (errorCode == 'auth/weak-password') {
        alert('The password is too weak.');
      } else {
        alert(errorMessage);
      }
      console.log(error);

    });
  });
}());

How do I solve the CORS request blocked?




Aucun commentaire:

Enregistrer un commentaire