Firebase电话认证与Google App Script Web App集成报错求助
Firebase电话认证在Google App Script Web App中报错“Hostname match not found”的解决方案
可行性确认
可以在Google App Script Web App中集成Firebase电话认证,你遇到的“Hostname match not found”错误是Firebase安全机制对未授权域名的拦截导致的,并非技术上不可行。
解决步骤
添加Firebase授权域名
- 进入Firebase控制台,找到你的项目,打开「Authentication」→「设置」→「授权域」
- 添加域名
script.googleusercontent.com(无需添加具体Web App路径,直接使用根域名) - 保存设置后等待5-10分钟,让配置全局生效
检查Web App部署权限
部署Web App时,将「Who has access to the app」设置为「Anyone, even anonymous」或对应授权范围,避免权限限制导致域名验证失败,部署完成后使用最新生成的URL访问。修正reCAPTCHA验证器配置
在前端初始化reCAPTCHA验证器时,不要手动指定domain参数,让Firebase自动适配当前Web App域名,示例代码:window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container', { 'size': 'invisible', 'callback': (response) => { onSignInSubmit(); }, 'expired-callback': () => { // 可在此添加reCAPTCHA过期后的重置逻辑 } }, firebase.auth());验证域名一致性
在Web App页面打开浏览器控制台,执行window.location.hostname,确认输出为script.googleusercontent.com;如果使用了自定义域名映射Web App,需同时将自定义域名添加到Firebase授权域列表。
额外排查点
- 确保Firebase控制台中已开启电话认证功能(「Authentication」→「Sign-in method」→「Phone」状态为启用)
- 尝试清除浏览器缓存或使用隐身窗口测试,避免旧配置缓存干扰
内容的提问来源于stack exchange,提问作者Gurminder Singh
相关产品推荐
相关产品推荐

