0
0
Firebasecloud~20 mins

Multiple site hosting in Firebase - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Firebase Multi-Site Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Architecture
intermediate
2:00remaining
How does Firebase handle multiple site hosting within a single project?

You have a Firebase project and want to host two different websites under the same project. How does Firebase manage this?

AFirebase requires creating separate projects for each site; multiple sites in one project are not supported.
BFirebase uses different branches in Git to host multiple sites from the same project.
CFirebase merges all site files into one public directory and serves them under different URLs automatically.
DFirebase allows multiple sites by defining separate hosting targets in the firebase.json file, each with its own public directory.
Attempts:
2 left
💡 Hint

Think about how configuration files define hosting behavior.

Configuration
intermediate
2:00remaining
What is the correct firebase.json snippet to host two sites named 'main' and 'blog'?

Choose the firebase.json snippet that correctly configures hosting for two sites: 'main' and 'blog', each with its own folder.

A{ "hosting": [ { "target": "main", "public": "main-site" }, { "target": "blog", "public": "blog-site" } ] }
B{ "hosting": { "main": { "public": "main-site" }, "blog": { "public": "blog-site" } } }
C{ "hosting": { "target": [ "main", "blog" ], "public": [ "main-site", "blog-site" ] } }
D{ "hosting": [ { "site": "main", "public": "main-site" }, { "site": "blog", "public": "blog-site" } ] }
Attempts:
2 left
💡 Hint

Look for the correct use of 'target' and array structure.

service_behavior
advanced
2:00remaining
What happens if you deploy multiple sites with overlapping public directories in Firebase?

You configure two hosting targets with the same public directory and deploy both. What is the expected behavior?

AFirebase throws an error during deployment and stops the process due to overlapping directories.
BFirebase deploys both sites successfully, but the last deployed site overwrites the files, causing conflicts.
CFirebase merges the files from both sites and serves a combined site without errors.
DFirebase ignores the second deployment and keeps the first site's files intact.
Attempts:
2 left
💡 Hint

Think about file system behavior when writing to the same folder twice.

security
advanced
2:00remaining
How can you restrict access to one of multiple Firebase hosted sites within the same project?

You have two sites hosted in one Firebase project. You want to restrict access to one site only to authenticated users. How can you achieve this?

AUse Firebase Hosting rewrite rules to redirect unauthenticated users to a login page for that site.
BUse Firebase Storage security rules to restrict access to the hosting files.
CSet up separate Firebase projects for each site to apply different security rules.
DConfigure Google Cloud IAM roles to block access to the site URL.
Attempts:
2 left
💡 Hint

Think about how hosting can control routing and access based on user state.

Best Practice
expert
3:00remaining
What is the recommended approach to manage environment-specific configurations for multiple Firebase hosted sites in one project?

You have multiple sites hosted in one Firebase project for different environments (dev, staging, production). How should you manage environment-specific settings like API keys or feature flags?

AUse Firebase Remote Config to manage environment variables dynamically for all sites.
BStore all environment configs in one file and use client-side code to select the right config based on URL.
CUse separate hosting targets with different public folders containing environment-specific config files, and deploy accordingly.
DManually edit the firebase.json file before each deployment to change environment variables.
Attempts:
2 left
💡 Hint

Consider how static files and deployment targets can separate environments.