fix guide
Firebase auth/unauthorized-domain after deploy
Harjot · · updated
Sign-in works on your laptop, then fails on the live site. The browser console shows auth/unauthorized-domain, or the Google sign-in window closes with an error about the domain.
Firebase only completes sign-in on domains in its Authorized domains list. Either your live address is missing from that list, or the config points at a domain that isn't on it. Check these three in order.
1. The live domain isn't in Authorized domains
Open the Firebase console, go to Authentication, then Settings, then Authorized domains. Click Add domain and type the host name your users see in the address bar, such as myapp.vercel.app or yourdomain.com. Firebase's Google sign-in docs say to add your custom domain to this list.
Save it, then reload the live site in a new private window and try sign-in again.
signs Sign-in fails on the live URL, and the console error names the domain.
2. The address differs from the one you added
Each host name is its own entry. www.yourdomain.com and yourdomain.com are two different host names, so add both if both load your app. A preview link on Vercel has its own host name, so it needs its own entry too.
Add each address you use, then check each one.
signs Sign-in works on one address of the site and fails on another.
3. The authDomain in your config is wrong
Firebase's config has an authDomain field. It tells the SDK which domain serves the sign-in handler. Firebase's redirect docs say the continue_uri must also be in the Authorized domains list.
If your app sets authDomain from an environment variable, and that variable is missing on the live site, the value reads as undefined and sign-in breaks. Set the variable for Production in Vercel, redeploy, and check the value on the live site.
signs The config shows authDomain as undefined, or as a domain you never added to the list.
Test it like a new user
- Open the live site in a new private window and click the sign-in button.
- Finish sign-in, then check the new user appears under Authentication, then Users, in the Firebase console.
- Repeat the test on every other address you use, such as the custom domain and a preview link.
- Check the browser console shows no auth/unauthorized-domain error.
Common questions
How do I fix auth/unauthorized-domain on my live Firebase site?
Add your live host name to Authorized domains. Open the Firebase console, go to Authentication, then Settings, then Authorized domains, and click Add domain. Type the host name from the address bar, such as yourdomain.com, then save and reload the live site in a new private window.
Why does Firebase sign-in work on www.yourdomain.com but fail on yourdomain.com?
Each host name is its own entry in Authorized domains. www.yourdomain.com and yourdomain.com are different, so add both if both load your app. A preview link on Vercel has its own host name and needs its own entry too.
What does authDomain do in my Firebase config, and why is it undefined?
authDomain tells the SDK which domain serves the sign-in handler. If your app reads it from an environment variable that is missing on the live site, the value is undefined and sign-in breaks. Set the variable for Production in Vercel, redeploy, then check the value on the live site.
Still stuck?
Not sure this is the cause? Paste your app's link into the free scan. It lists what a visitor's browser can see, like leaked keys and exposed files, worst first. The score is free; every fix as a prompt for your builder is $9, one-time.
Want a person to look inside? See the diagnosis