25

I have firebase hosting working successfully in my project however I want to use the same database for a different site on a subdomain so I thought I would click add another site on firebase hosting.

I can configure the a records etc for the domain with no issues but am having trouble deploying content to the secondary site.

For example if I run firebase init and follow the prompts my .firebaserc looks the same in both my main project and my sub project.

{
  "projects": {
    "default": "<project-name-here>"
  }
}

Is there a way to tell the file which hosting site you are trying to deploy to? I have seen references to multiple databases here but I don't think this is relevant to what I am trying to do?

Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
ak85
  • 4,154
  • 18
  • 68
  • 113

2 Answers2

29

You need to set deployment targets:

firebase target:apply hosting target-name resource-name

Where the parameters are:

  • target-name — a unique identifier (that you've defined yourself) for the Hosting site that you're deploying to

  • resource-name — the name of the Hosting site as listed in your Firebase project


Let me know if it works!

Source: https://firebase.google.com/docs/hosting/multisites

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Saxon B
  • 351
  • 3
  • 3
  • 10
    @Frank after reading the documentation and other posts I still feel there is no depth in any of the explanations. for eg. what is & ? is target name the name I give when I click on _Add Site_ ? And is resource name the name I give when I click on _Add App_ ? Do I have to edit my firebase.json with an array of **target** & **public** for every WebApp that is tied to this Firebase project? – Yo Apps Nov 22 '19 at 15:47
  • If you're having a hard time making this work, post a new question with the [minimal-but-complete steps that reproduce where you got stuck](http://stackoverflow.com/help/mcve). – Frank van Puffelen Nov 22 '19 at 16:14
  • What's the difference between "Hosting site that you're deploying to" and "the name of the Hosting site as listed"? – Oliver Dixon Sep 11 '20 at 12:30
  • 3
    Target-name is just something you make up when you run this command - an alias to call the site by. i.e. staging or prod. Resource-name is the site name (not project id). You can see your available sites on the hosting tab of firebase: https://console.firebase.google.com/project//hosting/main – DaveS Oct 27 '20 at 14:37
0

It's this one:

enter image description here

It's a text name you entered like my-firebase-app, not a generated string of characters.

And make sure you are logged in to firebase with the correct account, you'll obviously get issues if your not but could think they are a problem with the id. Maybe even run firebase logout, firebase login.

Kong
  • 8,792
  • 15
  • 68
  • 98