我目前正在使用Firebase开发Remix应用程序。我正试图使用GoogleProvider和signInWithEmanilAndPassword实现我的认证过程。在我的混音的行动时,我做了下面的实现能够登录,但我得到这个错误就在下面。
我需要你的帮助
Cannot read properties of undefined (reading '_getRecaptchaConfig')
字符串
混音动作函数
export async function action({ request }: ActionArgs) {
const formData = await request.formData()
// const userAgent = request.headers.get('user-agent') ?? ''
// const ua = UAParser(userAgent)
// const session = await getSession(request.headers.get('Cookie'))
const formValues = Object.fromEntries(formData)
invariant(
formValues?.email && typeof formValues?.email === 'string',
"email is empty or isn't a string type",
)
invariant(
formValues?.password && typeof formValues?.password === 'string',
"password is empty or isn't a string type",
)
try {
// await signOut(clientAuth)
const response = await createUserWithEmailAndPassword(
clientAuth,
formValues.email,
formValues?.password,
)
} catch (error) {
console.log('[] err', error)
logger.error(getErrorMessage(error))
}
return null
}
型
表单组件
<Form
method="post"
className="space-y-3"
action="/auth/signin"
{...form.props}
noValidate
replace
>
<fieldset>
<label htmlFor="email">{t('email')}</label>
<Input name="email" placeholder={`${t('email')}`} />
<p aria-invalid="true">{email.error}</p>
</fieldset>
<fieldset>
<label htmlFor="password">{t('password')}</label>
<Input
name="password"
type="password"
placeholder={`${t('password')}`}
/>
<p aria-invalid="true">{password.error}</p>
</fieldset>
<LoadingButton
type="submit"
size="lg"
name="intent"
value="__with_email"
isLoading={navigation.state === 'loading'}
className="mt-[18px] min-h-[56px] w-full text-base"
>
{t('createMyAccount')}
</LoadingButton>
<p className="mt-[18px] text-center text-base">
{t('alreadyMember')},{' '}
<Link to="/login" className="font-bold hover:underline">
{t('login')}
</Link>
</p>
</Form>
型
Firebase配置
import { getAuth } from 'firebase/auth'
import { initializeApp } from 'firebase/app'
console.log(process.env.FIREBASE_API_KEY)
export const firebaseConfig = {
apiKey: 'xxxxxxxxxxxxxxxxxxxx',
authDomain: 'xxxxxxxx',
projectId: 'xxxxxxxxxxx',
storageBucket: 'xxxxx',
messagingSenderId: 'xxxxxx',
appId: 'xxxxxxxxxxx',
measurementId: 'xxxxxxxx',
}
const app = initializeApp(firebaseConfig)
const auth = getAuth(app)
export { auth }
TypeError: Cannot read properties of undefined (reading '_getRecaptchaConfig')
at createUserWithEmailAndPassword (/Users/elyseebleu/Desktop/DEV/myInspo/node_modules/@firebase/auth/src/core/strategies/email_and_password.ts:291:20)
at action3 (/Users/elyseebleu/Desktop/DEV/myInspo/app/routes/auth+/signin.tsx:181:26)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Object.callRouteActionRR (/Users/elyseebleu/Desktop/DEV/myInspo/node_modules/@remix-run/node/node_modules/@remix-run/server-runtime/dist/data.js:35:16)
at callLoaderOrAction (/Users/elyseebleu/Desktop/DEV/myInspo/node_modules/@remix-run/router/router.ts:3568:16)
at submit (/Users/elyseebleu/Desktop/DEV/myInspo/node_modules/@remix-run/router/router.ts:2835:16)
at queryImpl (/Users/elyseebleu/Desktop/DEV/myInspo/node_modules/@remix-run/router/router.ts:2770:22)
at Object.queryRoute (/Users/elyseebleu/Desktop/DEV/myInspo/node_modules/@remix-run/router/router.ts:2720:18)
at handleDataRequestRR (/Users/elyseebleu/Desktop/DEV/myInspo/node_modules/@remix-run/node/node_modules/@remix-run/server-runtime/dist/server.js:75:20)
at requestHandler (/Users/elyseebleu/Desktop/DEV/myInspo/node_modules/@remix-run/node/node_modules/@remix-run/server-runtime/dist/server.js:49:18)
2条答案
按热度按时间tkclm6bt1#
我遇到了完全相同的问题,原来我只是把我的Firebase Auth对象设为undefined。
因此,请检查您的
clientAuth
是否正确定义。vaj7vani2#
你能修好吗?重新验证用户时出现相同错误