Setting authDomain on a hosted app?

293 views
Skip to first unread message

Jesse Boyes

unread,
Apr 23, 2020, 12:02:44 AM4/23/20
to Firebase Google Group
Hi all,

I've got what is hopefully a simple question: I'm building a web app that's hosted with Firebase hosting that I've pointed to my own domain, and enabled Google sign-in as an option. Hosting is all set up and working properly, except - when using the Google sign-in, the dialog confusingly reads "Sign in to continue to xxxxxxxx.firebaseapp.com", instead of my domain.

All of the documentation mentions that to change the domain in this Google sign-in dialog, set authDomain in the config to your new hosted domain. But! When using an app that's hosted on Firebase, the firebaseConfig and app initialization is managed by Firebase and not inside of your JavaScript.

So, how do I change the authDomain in this situation so that Google sign-in reads the correct domain?

Thanks for any help!

Jesse

Michael Bleigh

unread,
Apr 23, 2020, 2:09:23 PM4/23/20
to Firebase Google Group
Hi Jesse,

To clarify are you talking about initializing the Firebase JS SDK via `/__/firebase/init.js` on Firebase Hosting?

If so, you're correct that we don't currently customize or allow customization of the `authDomain`. This is something I'd be happy to take back to the team as a feature request.

In the meantime, something you could do (though it's a little more work) is fetch the config via `/__/firebase/init.json` and then manually change authDomain before passing it to firebase.initializeApp.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/8fdc8300-4b51-4ad1-8a84-92fd5ece4c79%40googlegroups.com.

Jesse Boyes

unread,
Apr 23, 2020, 4:19:24 PM4/23/20
to Firebase Google Group
Hi Michael -

Right! that's exactly what I'm talking about.

So correct me if I'm wrong, but it looks as if `/__/firebase/init.js` already calls firebase.initializeApp on your behalf. If you try to call firebase.initializeApp after including init, you'll get this:

Uncaught FirebaseError: Firebase: Firebase App named '[DEFAULT]' already exists (app/duplicate-app).

So there may be no way to inject a change into authDomain while initializing the Firebase JS SDK in this way?

Thanks for the response -

Jesse
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.

Kato Richardson

unread,
Apr 27, 2020, 12:51:55 PM4/27/20
to Firebase Google Group
That's right Jesse, initializeApp() is called. Docs are here, under "from hosting urls". Note how there is no call to initializeApp() in the setup.

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/cb628c65-5ac7-463c-9da0-337c7418a2cd%40googlegroups.com.


--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Kato Richardson

unread,
Apr 27, 2020, 12:52:09 PM4/27/20
to Firebase Google Group
Docs are here. : )
Reply all
Reply to author
Forward
0 new messages