Demo, all content is generated
Question

Firebase auth/unauthorized-domain after connecting my own domain

Solved · 612 views · asked by ellie_vc · edited

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 · edited

2 answers

Marked as helpful by the asker
sven_fire · edited

Firebase console → Authentication → Settings → Authorized domains → Add domain. Add both mydomain.com and www.mydomain.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 · edited
Happens to everyone once. sven_fire · edited
lukas_b · edited

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