This warning is puzzling me. I know it appears when you call initializeApp without arguments, and I understand that the warning is very appropriate under those circumstances.
A configuration based on the project id is valid for my project, and so to avoid the warning I then explicitely form this configuration before passing it on like so:
// GCP_PROJECT seems to be required for cloud-functions where GCLOUD_PROJECT is missing
const projectId = process.env.GCP_PROJECT || process.env.GCLOUD_PROJECT;
assert(projectId, "Missing GCP_PROJECT or GCLOUD_PROJECT env variable");
const firebaseConfig = {
authDomain: `${projectId}.firebaseapp.com`,
databaseURL: `https://${projectId}.firebaseio.com`,
projectId,
storageBucket: `${projectId}.appspot.com`,
};
Firebase continues to give me the same warning and I don't see a reason for that.
This code is both used in and outside of the context of cloud functions. If anyone from Google is listening, I think it would be useful to have a clear overview in de documentation what the differences are for various components in GCP regarding these environment variables:
GCP_PROJECT
, GCLOUD_PRJOJECT
and GOOGLE_CLOUD_PROJECT
. A while ago I read a mention that GCLOUD_PRJOJECT
was being deprecated, but it seems to be still in active use.
I'm using firebase-admin version 10 but the behavior was the same with 9 AFAIK.