【问题标题】:TypeError: Cannot create property 'href' on string 'about:blank'TypeError:无法在字符串“about:blank”上创建属性“href”
【发布时间】:2019-07-20 00:44:01
【问题描述】:

在 ElectronJS 上使用 Google 测试 Firebase 身份验证后遇到错误。

身份验证以前可以工作,尽管我没有对我的代码进行任何会影响 Google 身份验证部分的重大更改。

当我在浏览器中运行我的项目时,身份验证仍然可以正常工作(npm run serve)。在 Electron 中,我可以看到

TypeError: Cannot create property 'href' on string 'about:blank' when clicking on the Google authentication button.

TypeError: Cannot create property 'href' on string 'about:blank'

我的代码在点击时被执行 -

googleLogin() {
  fb.auth
    .signInWithPopup(fb.googleProvider)
    .then(credential => {
      this.$store.commit("setCurrentUser", credential.user)

      fb.usersCollection.doc(credential.user.uid).set({

      }).then(() => {
        this.$store.dispatch("fetchUserProfile")
        this.updateGmailData()
        this.$router.push("/dashboard")
      }).catch(err => {
        console.log(err)
      })
    }).catch(err => {
      console.log(err);
    });
},

第二次点击按钮,我可以看到另一个 typeError -

TypeError: Cannot create property 'href' on string ''

为什么身份验证在浏览器中有效,但在 Electron 中无效? 这个问题的原因是什么?

【问题讨论】:

    标签: firebase vue.js firebase-authentication electron


    【解决方案1】:

    请参阅此问题https://github.com/firebase/firebase-js-sdk/issues/1334

    Firebase Auth 不正式支持 Electron。由于 Electron 是浏览器和 Node.js 服务器环境的组合,因此某些功能可能无法按预期工作,例如 signInWithPopup。

    但是@diggabyte(感谢他)似乎找到了处理它的方法:

    我能够通过 signInWithRedirect + getRedirectResult 让它工作 https://github.com/firebase/firebase-js-sdk/issues/1334#issuecomment-434094783

    【讨论】:

      猜你喜欢
      • 2022-01-25
      • 2018-11-24
      • 2023-04-11
      • 1970-01-01
      • 2018-12-08
      • 1970-01-01
      • 2017-09-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多