You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决Firebase Auth未捕获类型错误:无法读取undefined的'appVerificationDisabledForTesting'属性

无法实例化RecaptchaVerifier(Firebase 10.8.0 + Vite + Firebase模拟器)

我在连接Firebase模拟器套件的Vite开发服务器上运行登录页面,当前Firebase版本为10.8.0,无法实例化新的RecaptchaVerifier。

相关代码

firebaseModular.js

const mainConfig = {
  apiKey: import.meta.env.VITE_API_KEY,
  authDomain: import.meta.env.VITE_AUTH_DOMAIN,
  projectId: import.meta.env.VITE_PROJECT_ID,
  storageBucket: import.meta.env.VITE_STORAGE_BUCKET,
  messagingSenderId: import.meta.env.VITE_MESSAGING_SENDER_ID,
  appId: import.meta.env.VITE_APP_ID,
  measurementId: import.meta.env.VITE_MEASUREMENT_ID,
};

export const firebaseApp = initializeApp(mainConfig, "modular");
export const auth = getAuth(firebaseApp);
getAuth(firebaseApp).settings.appVerificationDisabledForTesting = true;
// auth.settings.appVerificationDisabledForTesting = true;

SignInForm.js

import { auth } from "../../constants/firebaseModular";
import { signInWithEmailAndPassword, RecaptchaVerifier } from "firebase/auth";

const SignInForm = () => {
  ...
  console.log("auth settings in SignInForm", auth.settings);

  const recaptchaVerifier = new RecaptchaVerifier(
    "recaptcha-container",
    auth

补充说明

  • 已了解参数顺序相关讨论:将auth实例放在最后一位时,出现实例化失败错误;按多数建议将auth放在第一位时,抛出Uncaught FirebaseError: Firebase: Error (auth/argument-error)。
  • 运行时console.log输出的auth设置对象为{appVerificationDisabledForTesting: true}。
  • 在firebaseModular.js中,两种设置appVerificationDisabledForTesting为true的方式(启用行与注释行),产生的日志和错误完全一致。

更新尝试

移除firebaseModular.js中所有相关设置代码,修改SignInForm.jsx如下,但问题仍未解决:

import { auth, firebaseApp } from "../../constants/firebaseModular";
import { getAuth } from "firebase/auth";

const SignInForm = () => {
 ...

  console.log("auth settings in SignInForm before", auth.settings);
  getAuth(firebaseApp).settings.appVerificationDisabledForTesting = true;
  console.log("auth settings in SignInForm after", auth.settings);
  const recaptchaVerifier = new RecaptchaVerifier(
    "recaptcha-container",
    getAuth(firebaseApp)
  );

内容的提问来源于stack exchange,提问作者skmcloughlin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 11:52:33