【问题标题】:google button dose not work after deployment using firebase as database使用 firebase 作为数据库部署后,google 按钮不起作用
【发布时间】:2022-10-14 13:56:43
【问题描述】:

我基于firebase制作聊天应用程序。当我在本地主机上运行它时,它可以工作,但是当我部署它时,登录按钮无法正常工作。

我在 google 中打开了 oApi,并将网站添加到 Authorized JavaScript origins 和 Authorized redirect URIs,但仍然无法正常工作。

这是我的代码:

import { GoogleAuthProvider, signInWithRedirect } from 'firebase/auth'
import React from 'react'
import {auth} from "../firebase"
const googleSignIn = () =>{
 const provider = new GoogleAuthProvider()
 signInWithRedirect (auth, provider)    
}

const SingIn = () => {
  return (
    <div className="" >
        <button className='login-btn'  onClick={googleSignIn}>Login with google </button>
    </div>
  )
}

export default SingIn

【问题讨论】:

  • 你得到什么错误?
  • 当我按下该按钮时的错误没有发生任何事情,实际上应该出现谷歌窗口来选择要登录的帐户但不会发生这种情况。
  • 我猜你在浏览器的控制台中有错误

标签: javascript reactjs firebase firebase-authentication google-api


【解决方案1】:

它有效我应该将我的域添加到firebase中的授权域(身份验证->设置->授权域)然后它应该可以工作。

【讨论】:

    猜你喜欢
    • 2020-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-19
    • 2020-07-13
    相关资源
    最近更新 更多