【问题标题】:Firebase - sending verifyEmail emails from local or production environment domainsFirebase - 从本地或生产环境域发送 verifyEmail 电子邮件
【发布时间】:2019-12-14 22:51:42
【问题描述】:

我正在尝试将我的 firebase 设置配置为可以从我的开发或生产环境发送 verifyEmail 电子邮件。

我有一个 .env 文件,其中有两个设置,如下所示:

REACT_APP_PROD_CONFIRMATION_EMAIL_REDIRECT=https://example.com

REACT_APP_DEV_CONFIRMATION_EMAIL_REDIRECT=http://localhost:3000

然后在我的 firebase 配置文件中:

doSendEmailVerification = () =>
      this.auth.currentUser.sendEmailVerification({

      url: process.env.NODE_ENV === 'production' ? process.env.REACT_APP_PROD_CONFIRMATION_EMAIL_REDIRECT : process.env.REACT_APP_DEV_CONFIRMATION_EMAIL_REDIRECT,
      }); 

当我在开发环境中进行测试时,这很好用。

当我部署该版本并尝试在生产中对其进行测试时 - 电子邮件不会发送。

两个 firebase 帐户的配置方式相同,以发送电子邮件。

没有生成错误消息,我的提交处理程序中的步骤被跳过了。

我的提交处理程序有:

this.props.firebase
    .doCreateUserWithEmailAndPassword(values.email, values.password)
    .then(authUser => {
    return this.props.firebase.user(authUser.user.uid).set(
        {
          name: values.name,
          email: values.email,
          createdAt: new Date()

        },
        { merge: true },
    );
    })
    .then(() => {
      return this.props.firebase.doSendEmailVerification();
      })
    .then(() => {
      this.setState({ ...initialValues });
      this.props.history.push(ROUTES.DASHBOARD);

【问题讨论】:

    标签: javascript firebase google-cloud-firestore firebase-authentication


    【解决方案1】:

    您必须在 firebase 的“身份验证”部分中将您的域列入白名单才能正常工作。我在这里看到了几篇帖子说不再需要白名单步骤 - 但对我来说,它是。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-02
      • 2021-03-21
      • 2016-03-20
      • 2011-06-20
      • 2017-06-07
      • 2012-05-04
      • 2018-12-07
      • 1970-01-01
      相关资源
      最近更新 更多