Question

Firebase auth/unauthorized-domain after connecting my own domain

Solved · 612 viewsasked by ellie_vc

Moved my app from the .web.app address to my own domain. Google login popup now closes immediately and the console shows

FirebaseError: Firebase: Error (auth/unauthorized-domain).

Everything else works on the new domain.

What I’ve tried

Windsurf changed the authDomain in the firebase config to my new domain, which made it worse (popup shows a 404).

Comment
Authorized domains list in the Firebase console. Two minutes, answer below. sven_fire

2 answers

Marked as helpful by the asker
sven_fire

Firebase console → Authentication → Settings → Authorized domains → Add domain. Add both example.com and www.example.com if you use both.

And put authDomain back to yourproject.firebaseapp.com. Pointing authDomain at your own domain only works if that domain serves Firebase's /__/auth/ handler (which it does on Firebase Hosting with extra setup), that's why you got a 404.

Comment
Added the domain, reverted authDomain, works. Was 2 minutes, I spent 2 hours before asking. ellie_vc
Happens to everyone once. sven_fire
lukas_b

Later on, if Safari users get stuck in a login loop with the redirect flow, that's when you do the custom authDomain setup properly. The Firebase docs have a page on redirect best practices for exactly that.

Comment