Environment configuration in Firebase means setting up different settings for your app depending on where it runs, like development, testing, or production. It helps keep things organized and safe.
Click to reveal answer
beginner
How do Firebase environment configurations help in app development?
They let you use different databases, APIs, or keys for development and production. This way, you avoid mixing test data with real data and keep your app secure.
Click to reveal answer
intermediate
What Firebase tool helps manage multiple environment configurations easily?
Firebase CLI (Command Line Interface) allows you to create and switch between different project aliases representing environments like dev, staging, and prod.
Click to reveal answer
beginner
Why should you avoid hardcoding API keys in your Firebase app?
Hardcoding keys can expose them publicly, risking security. Instead, use environment configuration to keep keys safe and change them easily without changing code.
Click to reveal answer
intermediate
What is the purpose of Firebase project aliases in environment configuration?
Project aliases let you name different Firebase projects (like dev or prod) so you can deploy and test your app in different environments without confusion.
Click to reveal answer
What does environment configuration in Firebase help you manage?
ADifferent settings for development and production
BOnly the app's user interface
CFirebase billing plans
DFirebase storage size
✗ Incorrect
Environment configuration helps manage different settings like databases and keys for development and production.
Which Firebase tool allows switching between different environment projects?
AFirebase Hosting
BFirebase Console
CFirebase CLI
DFirebase Analytics
✗ Incorrect
Firebase CLI lets you create and switch between project aliases for different environments.
Why should API keys not be hardcoded in Firebase apps?
AThey slow down the app
BThey are not supported by Firebase
CThey increase app size
DThey can be exposed and cause security risks
✗ Incorrect
Hardcoded keys can be seen by others, risking security. Environment configuration keeps them safe.
What is a Firebase project alias used for?
AManaging user roles
BNaming different Firebase projects for environments
CChanging app colors
DTracking app crashes
✗ Incorrect
Project aliases help identify different Firebase projects like dev or prod for easy management.
Which environment is typically used to test new features before production?
AStaging
BProduction
CDevelopment
DArchived
✗ Incorrect
Staging is used to test new features in an environment similar to production before release.
Explain how environment configuration improves Firebase app security and management.
Think about how different environments keep data and keys safe and organized.
You got /4 concepts.
Describe the steps to set up multiple environments in Firebase using the CLI.
Focus on commands and how to switch between environments.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of environment configuration in Firebase functions?
easy
A. To create new Firebase projects
B. To write the main logic of the function
C. To deploy the Firebase project
D. To store settings outside the code for security and flexibility
Solution
Step 1: Understand environment configuration role
Environment configuration holds settings like API keys or URLs outside the code to keep them safe and easy to change.
Step 2: Compare options with this role
Only To store settings outside the code for security and flexibility describes storing settings outside code for security and flexibility, which matches the purpose.
Final Answer:
To store settings outside the code for security and flexibility -> Option D
Quick Check:
Environment config = store settings outside code [OK]
2. Which command correctly sets an environment variable named api.key with value 12345 in Firebase functions?
easy
A. firebase config:set api.key 12345
B. firebase functions:config:set api.key=12345
C. firebase functions:set-config api.key=12345
D. firebase functions:config add api.key 12345
Solution
Step 1: Recall correct syntax for setting config
The correct command uses 'firebase functions:config:set' followed by key=value pairs.
Step 2: Match options to syntax
Only firebase functions:config:set api.key=12345 matches the exact syntax: 'firebase functions:config:set api.key=12345'. Others have wrong commands or missing colons.
Final Answer:
firebase functions:config:set api.key=12345 -> Option B
Quick Check:
Set config = functions:config:set key=value [OK]
Hint: Use 'functions:config:set key=value' to set env vars [OK]
Common Mistakes:
Omitting the colon after 'functions'
Using spaces instead of '=' between key and value
Using wrong command verbs like 'add' or 'set-config'
3. Given the following commands run in order: firebase functions:config:set service.api_key="abc123" firebase deploy --only functions
What will functions.config().service.api_key return inside your function?
medium
A. service.api_key
B. undefined
C. "abc123"
D. null
Solution
Step 1: Understand setting and deploying config
Setting 'service.api_key' with value 'abc123' and then deploying functions makes the config available inside functions.
Step 2: Accessing config in function
Accessing 'functions.config().service.api_key' returns the string value set, which is 'abc123'.
Final Answer:
"abc123" -> Option C
Quick Check:
Config value = "abc123" after deploy [OK]
Hint: Deploy after setting config to access values [OK]
Common Mistakes:
Forgetting to redeploy functions after setting config
Expecting config to be available without deploy
Confusing key names or accessing wrong path
4. You set an environment variable with firebase functions:config:set db.url="https://mydb.com" but inside your function functions.config().db.url returns undefined. What is the most likely cause?
medium
A. You forgot to redeploy the functions after setting the config
B. The config key name is invalid
C. You need to restart the Firebase CLI
D. The value must be a number, not a string
Solution
Step 1: Identify cause of undefined config
Config values only update inside functions after redeploying them.
Step 2: Check other options
Key names can be strings, no CLI restart needed, and values can be strings. So these are not causes.
Final Answer:
You forgot to redeploy the functions after setting the config -> Option A
Quick Check:
Redeploy needed after config change [OK]
Hint: Always redeploy functions after config changes [OK]
Common Mistakes:
Assuming config updates instantly without deploy
Restarting CLI unnecessarily
Thinking config keys must be numbers
5. You want to store two environment variables for your Firebase functions: api.key with value key123 and api.secret with value secret456. Which command correctly sets both at once?
hard
A. firebase functions:config:set api.key=key123 api.secret=secret456
B. firebase functions:config:set api.key=key123; api.secret=secret456
C. firebase functions:config:set api.key=key123, api.secret=secret456
D. firebase functions:config:set api.key=key123 && api.secret=secret456
Solution
Step 1: Recall syntax for multiple config keys
Multiple keys are set by listing them separated by spaces, each as key=value pairs.
Step 2: Evaluate options
Only firebase functions:config:set api.key=key123 api.secret=secret456 uses spaces correctly. Others use semicolon, comma, or && which are invalid here.
Final Answer:
firebase functions:config:set api.key=key123 api.secret=secret456 -> Option A
Quick Check:
Multiple keys set with spaces [OK]
Hint: Separate multiple keys with spaces, not commas or semicolons [OK]
Common Mistakes:
Using commas or semicolons instead of spaces
Trying to chain commands with &&
Setting keys one at a time unnecessarily
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.