英文:
Firebase: Cannot read properties of undefined (reading '_getRecaptchaConfig')
问题
我需要你的帮助。
无法读取未定义的属性(读取 '_getRecaptchaConfig')
Remix 动作函数
export async function action({ request }: ActionArgs) {
const formData = await request.formData()
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 {
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 }
类型错误:无法读取未定义的属性(读取 '_getRecaptchaConfig')
在 createUserWithEmailAndPassword (/Users/elyseebleu/Desktop/DEV/myInspo/node_modules/@firebase/auth/src/core/strategies/email_and_password.ts:291:20)
在 action3 (/Users/elyseebleu/Desktop/DEV/myInspo/app/routes/auth+/signin.tsx:181:26)
在 runMicrotasks (<anonymous>)
在 processTicksAndRejections (node:internal/process/task_queues:96:5)
在 Object.callRouteActionRR (/Users/elyseebleu/Desktop/DEV/myInspo/node_modules/@remix-run/node/node_modules/@remix-run/server-runtime/dist/data.js:35:16)
在 callLoaderOrAction (/Users/elyseebleu/Desktop/DEV/myInspo/node_modules/@remix-run/router/router.ts:3568:16)
在 submit (/Users/elyseebleu/Desktop/DEV/myInspo/node_modules/@remix-run/router/router.ts:2835:16)
在 queryImpl (/Users/elyseebleu/Desktop/DEV/myInspo/node_modules/@remix-run/router/router.ts:2770:22)
在 Object.queryRoute (/Users/elyseebleu/Desktop/DEV/myInspo/node_modules/@remix-run/router/router.ts:2720:18)
在 handleDataRequestRR (/Users/elyseebleu/Desktop/DEV/myInspo/node_modules/@remix-run/node/node_modules/@remix-run/server-runtime/dist/server.js:75:20)
在 requestHandler (/Users/elyseebleu/Desktop/DEV/myInspo/node_modules/@remix-run/node/node_modules/@remix-run/server-runtime/dist/server.js:49:18)
希望这些信息对解决问题有所帮助。
英文:
I'm currently working on a Remix app with Firebase. I'm trying to implement my auth process using GoogleProvider and signInWithEmanilAndPassword. In my Remix's action when I did this implementation below to be able to signin but I get this error just below.
I need your help
Cannot read properties of undefined (reading '_getRecaptchaConfig')
Remix action function
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 component
<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 config
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)
答案1
得分: 1
我遇到了完全相同的问题,原来是我的 Firebase Auth 对象未定义。
所以,请检查你的 clientAuth
是否正确定义。
英文:
I had the exact same issue, turns out that I just had my Firebase Auth object as undefined.
So check that your clientAuth
is correctly defined.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论