PvDev
PvDev

Reputation: 829

How to initialise multiple apps from firestore using aws ec2 engine?

I am using same firestore database for multiple apps like iOS and android. And i have done backend for push notification using node js. Right now, I am trying to deploy backend in ec2 engine using AWS. While running server temporally in in terminal, I used command node index.js and console output shows Warning, FIREBASE_CONFIG environment variable is missing. Initializing firebase-admin will fail.

here the screenshot of database enter image description here

here is the console output from terminal enter image description here

here is the code used in node js

admin.initializeApp(functions.config().firebase);

admin.initializeApp({
credential: admin.credential.cert({
projectId: '',
clientEmail: '',
privateKey: ''
}),
databaseURL: ''
});

Upvotes: 2

Views: 759

Answers (1)

Ryan
Ryan

Reputation: 750

Assign the initialization to a variable and add a second argument of any string. This will let it know it is a secondary initialization. Take a look at the documentation.

var second = admin.initializeApp({
    credential: admin.credential.cert({
        projectId: '',
        clientEmail: '',
        privateKey: ''
    }),
    databaseURL: ''
}, 'secondary');

Upvotes: 2

Related Questions