Complete the code to initialize Firebase with the correct environment configuration.
const firebaseConfig = {
apiKey: "[1]",
authDomain: "your-app.firebaseapp.com",
projectId: "your-app",
storageBucket: "your-app.appspot.com",
messagingSenderId: "1234567890",
appId: "1:1234567890:web:abcdef123456"
};Use process.env.FIREBASE_API_KEY to securely access the API key from environment variables.
Complete the code to load environment variables from a .env file using Firebase CLI.
firebase functions:config:get > .runtimeconfig.json const functions = require('firebase-functions'); const config = functions.config(); console.log(config.[1]);
Firebase environment config keys are usually lowercase with underscores, like api_key.
Fix the error in accessing the Firebase environment variable in this code snippet.
const apiKey = process.env.[1]; if (!apiKey) { throw new Error('Missing Firebase API key'); }
The environment variable name must exactly match FIREBASE_API_KEY to be found.
Fill both blanks to correctly set and access Firebase environment variables in functions.
firebase functions:config:set [1]="your_api_key" const apiKey = functions.config().[2];
Use the same key firebase_api_key when setting and accessing environment variables.
Fill all three blanks to securely use Firebase environment variables in your Cloud Function.
exports.myFunction = functions.https.onRequest((req, res) => {
const apiKey = functions.config().[1];
if (!apiKey) {
res.status(500).send('[2]');
return;
}
res.send(`API Key is: [3]`);
});Use firebase_api_key to access the key, send a clear error message if missing, and use template literals to display the key.