0

I want to use the same firebase project for multiple websites. How do I get this working on browser and cloud functions?

Browser

firebase.initializeApp({
  apiKey: "***********************",
  authDomain: "domain1.com",
  databaseURL: "https://domain.firebaseio.com",
  projectId: "domain",
  storageBucket: "",
  messagingSenderId: "-----------",
  appId: "-------------"
});

If I change "domain1.com" to "domain2.com", will it work without issues? What happens to registered users in firebase? Will it be a combination of domain1.com and domain2.com?

Cloud functions

Will admin.database() return the domain.firebaseio.com RTDB irrespective of users logging into domain1.com or domain2.com? What happens to:

const tokenId = req.get('Authorization').split('Bearer ')[1];
admin.auth().verifyIdToken(idToken);

Thanks!

Réti Opening
  • 1
  • 1
  • 6
  • 21

1 Answers1

0

The hostname or domain name of your site doesn't much matter to Realtime Database. It is only an issue for Firebase Authentication. As long as you've added each domain to the project in the Firebase console, things will work as you expect with the same configuration for each site. Your sites will share the same set of users for the one project they are connected to.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441