部署到 Heroku 后,firebase 身份验证无法正常工作。仍然可以在 localhost:4200 的开发环境中工作

Yun*_*fin 3 heroku node.js express firebase-authentication angularfire2

将我的 Angular 7 应用程序部署到 heroku 后;我的 Google 和 Facebook 的 Firebase 身份验证不再有效。两者都显示相同的错误消息(如下)。即使在隐身模式下,它们也会显示相同的错误消息(与下面的相同)。

我已在我的 firebase 授权域中将 myDomain.com 和 myDomain.herokuapp.com 列入白名单。我还将 myDomain.herokuapp.com 添加到我的 Google 开发控制台的授权域中。

glogin() {
    this.socialLogin(new auth.GoogleAuthProvider());
  }
fbLogin() {
        this.socialLogin(new auth.FacebookAuthProvider());
      }
socialLogin(provider) {
  this.afAuth.auth.signInWithRedirect(provider)
    .then((user) => {
      console.log('Sign in with google: ', user);
    }).catch(() => {
    // Todo - something went wrong
  });
  }
Run Code Online (Sandbox Code Playgroud)

我得到的错误是:

Uncaught (in promise): Error: Cannot match any routes. URL Segment: '__/auth/handler'
Error: Cannot match any routes. URL Segment: '__/auth/handler'
Run Code Online (Sandbox Code Playgroud)

Uncaught (in promise): Error: Cannot match any routes. URL Segment: '__/auth/iframe'
Error: Cannot match any routes. URL Segment: '__/auth/iframe'
Run Code Online (Sandbox Code Playgroud)

Uncaught Error: Network Error
    at main.115259c96fcb9456163d.js:1
    at o (main.115259c96fcb9456163d.js:1)
    at e.invokeTask (polyfills.ef2a861f18352d657dcf.js:1)
    at t.runTask (polyfills.ef2a861f18352d657dcf.js:1)
    at t.invokeTask (polyfills.ef2a861f18352d657dcf.js:1)
    at invoke (polyfills.ef2a861f18352d657dcf.js:1)
    at n.args.<computed> (polyfills.ef2a861f18352d657dcf.js:1)
Run Code Online (Sandbox Code Playgroud)

小智 5

如果即使在实施上述方法后您仍然像我一样挣扎,只需转到您的 Firebase 控制台并在“登录方法”下的“授权域”选项卡上添加您的 Heroku 应用程序域。