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

Firebase邮箱密码认证异常:验证后重定向缺失providerId报错

Firebase邮箱验证后跳转错误URL问题排查求助

使用firebase/auth中的createUserWithEmailAndPassword创建用户后,Firebase会向用户发送邮箱验证邮件。验证链接可成功完成邮箱验证,但未重定向回应用,而是跳转到错误URL,具体情况如下:

本地模拟器环境

错误URL:

http://localhost:9099/emulator/auth/handler?apiKey=fake-api-key&appName=%5BDEFAULT%5D&authType=reauthViaRedirect&redirectUrl=http%3A%2F%2Flocalhost%3A3000%2Fapp&v=9.21.0&eventId=VBnwo5RI30cI7UvoCwfBQfZXNmmm%3A%3A%3A7630387099

对应错误信息:

{ "authEmulator": { "error": "missing apiKey or providerId query parameters" } }

本地后端通过调用admin.auth().generateEmailVerificationLink(email, { url: "http://localhost:3000/app"})生成验证链接,格式如下:

http://127.0.0.1:9099/emulator/action?mode=verifyEmail&lang=en&oobCode=XXX&apiKey=fake-api-key&continueUrl=http%3A%2F%2Flocalhost%3A3000%2Fapp

验证成功后会自动重定向到localhost:3000/app,但很快又跳转到上述错误URL。

生产环境

错误URL:

https://example.com/__/auth/handler?apiKey=XXX&appName=%5BDEFAULT%5D&authType=reauthViaRedirect&redirectUrl=https%3A%2F%2Fexample.com%2Fapp%2Fregister%2Fverify-email&v=9.21.0&eventId=TIaOYg0R5QdkPxrXuZl5IClNFd52%3A%3A%3A9624473175

对应错误信息:

The requested action is invalid.
...
Request is missing required data

生产环境通过前端调用sendEmailVerification(auth.currentUser, { url: window.location.href })让Firebase处理验证邮件,未使用自定义邮件操作处理器。已在Firebase控制台设置操作URL为https://example.com/__/auth/action并完成域名验证,也尝试过默认URL,问题依旧。生成的验证链接格式如下:

https://example.com/__/auth/action?mode=verifyEmail&oobCode=XXX&apiKey=XXX&continueUrl=https%3A%2F%example.com%2Fapp%2Fregister%2Fverify-email&lang=en

补充细节

  • 手动访问本地localhost:3000/app或生产环境https://example.com/app,可正常使用无异常。
  • 在错误URL的查询参数中添加&providerId=password后即可正常工作,但不清楚该错误URL的生成来源及缺失providerId的原因,希望得到问题排查及解决的帮助。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.22 09:55:30