Hosting multiple sites in Firebase

Problem Statement

The firebase tools for deploying sites in multiple hosting under a single project does not seem to work out of the box

Firebase is a nice platform for developers to quickly develop smart apps. I would like to share some experience regarding the github issue with firebase discussed here. . The root cause of the problem is that the `firebase target:apply` doesn’t change `firebase.json` — it only effects `.firebaserc`.

How to deploy multiple sites then ?

As a developer, i came across of the problem of trying to deploy multiple sites under a single firebase project. Let’s say you want to build a web app with an admin platform and a customer facing site. We would normally want to share the same project and host different sites under one project.

firebase-single-project

Image showing two hosting sites under a single project

A traditional firebase app deployment steps are listed here . Assuming you want to deploy more than one app under different hosts within the same project, you will follow standard firebase instructions listed here

If you try the link you will notice that, the default firebase.json does not get updated when you try
firebase target:apply hosting {yoursite-alias} {yoursite-name-in-firebase} [this command updates only the .firebaserc]

Instructions

Follow the below instructions to fix the problem

1. firebase target:apply hosting ecom-alias ecomadmin

2. change the firebase.json to have entries for each hosting site like

firebase-site-under

ecom-alias in this image is mapped to the ecomadmin site under firebase

3.firebase deploy — only hosting:ecom-alias

Output

1.firebase login

Allow Firebase to collect anonymous CLI usage and error reporting information? Yes

Visit this URL on any device to log in:

https://accounts.google.com/o/oauth2/auth?client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com&scope=email%20openid%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloudplatformprojects.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Ffirebase%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&response_type=code&state=534032544&redirect_uri=http%3A%2F%2Flocalhost%3A9005

Waiting for authentication…

✔ Success! Logged in as venkat86.careers@gmail.com

2.firebase init

(make some selections and then you see this)

✔ Wrote public/index.html

Writing configuration info to firebase.json

Writing project information to .firebaserc

Writing gitignore file to .gitignore

✔ Firebase initialization complete!

3.firebase target:apply hosting ecom-alias ecomadmin

Applied hosting target ecom-alias to  ecomadmin

4. firebase deploy — only hosting:ecom-alias

=== Deploying to ‘firenut-5411a’…

 deploying hosting

i hosting[ecomadmin]: beginning deploy…

i hosting[ecomadmin]: found 1 files in public

✔ hosting[ecomadmin]: file upload complete

i hosting[ecomadmin]: finalizing version…

✔ hosting[ecomadmin]: version finalized

i hosting[ecomadmin]: releasing new version

✔ hosting[ecomadmin]: release complete

✔ Deploy complete!

Project Console: https://console.firebase.google.com/project/firenut-5411a/overview

Hosting URL: https://ecomadmin.firebaseapp.com

Facebook
Twitter
LinkedIn

Related Posts

Mastering Medical Software Development: Key Technologies and Processes

The healthcare industry is undergoing a rapid digital transformation, driven by the increasing adoption of

A visual representation of a customer's journey through the banking process, with CRM solutions enhancing each touchpoint.

Beyond Transactions: Building Lasting Bonds with CRM Solutions in Banking

In the ever-evolving landscape of banking, a profound transformation is underway as institutions increasingly turn

Blog banner designed by Dorustree on topic How technology is solving workforce challenges in Healthcare industry

How technology is solving workforce challenges in Healthcare ?

In navigating healthcare’s persistent workforce challenges, technology emerges as the guiding force. Its impact spans