Search code examples
firebasefirebase-hosting

FIREBASE Hosting can't use the correct site


I have the following two hostings set up in my Firebase hosting. I don't know where the first one with the bad name came from, but anyway it's there and it's always coming up when I use firebase init from the command line as the only hosting I can use. Does anyone know how i can use Firebase init to connect my website to the second hosting address, that's the lbdsapp address? Also preferably I'd like to delete the lbds-aeb3d if possible and make the other one the default.F Any help would be really appreciated. Thanks.

enter image description here


Solution

  • The first site lbds-aeb3d is the main site created from your project ID, When you create the project you probably entered lbds which is too short for a project ID, so some random string is automatically added. So you can not delete it since it's associated with your project.

    Since you have added another site, that makes your project a multisites hosting project and you will have to configure .firebaserc and firebase.json accordingly.

    You can start by giving your secondary site a name to refer to when you want set it as a deploy target. You can do this by the following command

    firebase target:apply hosting <target-name> <resource-name>
    

    In your case, if you call it myapp it would be

    firebase target:apply hosting myapp lbdsapp
    

    Then firebase will generate .firebaserc that include myapp as a target

    Next, you'll have to define hosting configuration for your site in firebase.json

    You will have to add the target name in the hosting config. Note that if you have more sites, you will have to configure hosting as array of config objects

    {
      "hosting": {
          "target": "myapp",
          "public": ...,
          // ...
    
      }
    }
    

    When you deploy your site, you will have to specify the target

    firebase deploy --only hosting:myapp