Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/383.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 反应+;尝试登录Google时,Firebase应用程序和网络在auth.esm.js:255处出错_Javascript_Reactjs_Firebase_Firebase Authentication - Fatal编程技术网

Javascript 反应+;尝试登录Google时,Firebase应用程序和网络在auth.esm.js:255处出错

Javascript 反应+;尝试登录Google时,Firebase应用程序和网络在auth.esm.js:255处出错,javascript,reactjs,firebase,firebase-authentication,Javascript,Reactjs,Firebase,Firebase Authentication,我对解决Firebase/React应用程序中的网络错误失去了希望。错误Uncaught error:auth.esm.js:255处的网络错误有时会显示在控制台中,有时则不会显示,用户会成功登录Google 在搜索答案时,我找不到任何结论(无论是堆栈溢出还是Github问题)。Firebase文档仅显示在发生网络错误(如超时、连接中断或无法访问主机)时抛出的 下面是我的登录组件代码 useEffect(() => { auth .getRedirectResult()

我对解决Firebase/React应用程序中的网络错误失去了希望。错误
Uncaught error:auth.esm.js:255处的网络错误有时会显示在控制台中,有时则不会显示,用户会成功登录Google

在搜索答案时,我找不到任何结论(无论是堆栈溢出还是Github问题)。Firebase文档仅显示在发生网络错误(如超时、连接中断或无法访问主机)时抛出的

下面是我的登录组件代码

useEffect(() => {
    auth
      .getRedirectResult()
      .then(function (result) {
        if (result.credential) {
          const token = result.credential.accessToken
          setIdToken(token)
          history.push('/')
        }
        const user = result.user
        setUsername(user.displayName)
      })
      .catch(function (error) {
        var errorCode = error.code
        var errorMessage = error.message
        console.log('errorCode and errorMessage: ', errorCode, errorMessage)
      })
  }, [])

function handleSignInWithGoogle() {
    signInWithGoogle()
    setLoading(true)
  }

  //then, inside of my return statement

<button onClick={() => handleSignInWithGoogle()}> Sign in with Google </button>

您可能在代码或任何阻塞进程上有一些调试器


另外firebase有一个超时,在超时之后(我的情况下是几秒钟),它不允许您,一拿出阻止第一次启动的调试器,问题就解决了。

我正在开发还原程序,意外地得到了相同的错误:auth.esm.js:255未捕获错误:auth.esm.js:255I的网络错误,我在这方面失去了一些理智,最后我发现我的证件错了,因为我换了一张made@NathanPB你在哪里找到这些凭据以及如何更改它们?@kiabbott我记不太清楚,但在firebase控制台网站上会有一些按钮,如“将firebase添加到你的web应用程序”然后谷歌会为你提供一个JSON和你的凭证/配置
firebase.initializeApp(firebaseConfig)
export const firestore = firebase.firestore()
export const auth = firebase.auth()
export const provider = new firebase.auth.GoogleAuthProvider()
export const signInWithGoogle = () => auth.signInWithRedirect(provider)