【问题标题】:Google Firebase Auth Failed on Netlify, But work on local serverGoogle Firebase Auth 在 Netlify 上失败,但在本地服务器上工作
【发布时间】:2021-04-21 02:02:18
【问题描述】:

当我将我的网站部署到 netlify 时,我无法正常登录,新的 google 窗口自动打开和关闭,我的网站 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

我在netlify上部署后才出现在web上,并且在本地服务器上正常工作

【问题讨论】:

  • 您是否将 netlify 域添加到 Firebase 控制台的允许列表中?

标签: reactjs firebase firebase-authentication netlify


【解决方案1】:

将您当前的 netlify 域添加到 firebase 控制台

首先进入这个网址:https://console.firebase.google.com/u/0/project/your_project_name/authentication/providers

然后转到Authorised domains部分并添加https://kreivc-clock.netlify.app/

永远记得检查身份验证错误并提醒它:

const signIn = () => {
    auth
      .signInWithPopup(provider)
      .catch((error) => alert(error.message));
  };

【讨论】:

    猜你喜欢
    • 2020-12-02
    • 2019-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-22
    • 2021-07-06
    • 1970-01-01
    相关资源
    最近更新 更多