I want to avoid hard coding the default bucket name in a Firebase project. How do I get it on server side?
const admin = require("firebase-admin");
const defaultBucket = admin.storage().bucket();
const defaultBucketName = ...?
It turns out that the information is stored in an environment variable but not imported into the admin tooling directly. So the best way I have found to prepare your environment to serve the default bucket name is as follows:
const firebaseConfig = JSON.parse(process.env.FIREBASE_CONFIG!);
admin.initializeApp({
credential: admin.credential.applicationDefault(),
storageBucket: firebaseConfig.storageBucket,
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.