Error: Assertion failed: resolving hosting target of a site with no site name or target name -> Deploying change in Firebase Hosting to Live site
Asked Answered
B

8

11
{
  "database": {
    "rules": "database.rules.json"
  },
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "hosting": [
    {
      "public": "dist/nur",
      "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
      ],
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ]
    },
    {
      "target": "nur",
      "public": "dist/nur",
      "ignore": [
        "**/.*"
      ],
      "headers": [
        {
          "source": "*.[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].+(css|js)",
          "headers": [
            {
              "key": "Cache-Control",
              "value": "public,max-age=31536000,immutable"
            }
          ]
        },
        {
          "source": "/@(ngsw-worker.js|ngsw.json)",
          "headers": [
            {
              "key": "Cache-Control",
              "value": "no-cache"
            }
          ]
        }
      ],
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ]
    }
  ],
  "storage": {
    "rules": "storage.rules"
  }
}


Tried firebase deploy command through Firebase to deploy the changes.

Deploying to 'nur-beta'...

i  deploying database, storage, firestore, hosting
i  database: checking rules syntax...
database: rules syntax for database nur-beta-default-rtdb is valid
i  firebase.storage: checking storage.rules for compilation errors...
firebase.storage: rules file storage.rules compiled successfully
i  firestore: reading indexes from firestore.indexes.json...
i  cloud.firestore: checking firestore.rules for compilation errors...
cloud.firestore: rules file firestore.rules compiled successfully

After all resources deployement it gives assertion failed message.

Error: Assertion failed: resolving hosting target of a site with no site name or target name. This should have caused an error earlier. May I know what I'm missing while deploying the changes to already LIVE web-site hosted under Firebase Hosting.

Burnette answered 3/2, 2023 at 11:3 Comment(0)
C
0

There is no problem with your JSON file.

For deployment to firebase hosting first of all you have to build your project then you push your project to firebase hosting

command to build the project and deploy it to firebase

  1. For angular use the ng build command in the terminal of your project location.
  2. after building run the firebase deploy command
  3. See the Magic
Coessential answered 14/2, 2023 at 10:7 Comment(1)
yes, it worked yogesh. thanks for guiding me with the right steps.Burnette
R
35

You just have to log in to the console again.

firebase login --reauth
Refulgent answered 19/3, 2024 at 4:45 Comment(0)
M
14

Log out and login in again, at least that's what worked for me

Marentic answered 9/12, 2023 at 18:27 Comment(0)
M
4

I had the same issue, I fixed it by running firebase init and reinitializing the project.

Madriene answered 11/2, 2023 at 18:32 Comment(0)
B
1
"hosting": [
{
  "source": ".",
  "ignore": [
    "firebase.json",
    "**/.*",
    "**/node_modules/**"
  ],
  "frameworksBackend": {
    "region": "asia-east1"
  }
},
{
  "target": "friendly-travels",
  "source": ".",
  "frameworksBackend": {}
}
],

In the first block of the Hosting section, add the entire target line that is in the second block like this

"hosting": [
{
  "target": "friendly-travels",
  "source": ".",
  "ignore": [
    "firebase.json",
    "**/.*",
    "**/node_modules/**"
  ],
  "frameworksBackend": {
    "region": "asia-east1"
  }
},
{
  "target": "friendly-travels",
  "source": ".",
  "frameworksBackend": {}
}
],
Branny answered 13/11, 2023 at 0:45 Comment(0)
C
1

I was logged in with a different user that had no project like this one. Relogin with the correct user could be a solution if you are sure that the project/site exists.

Certificate answered 27/3, 2024 at 9:26 Comment(0)
I
0

I ran into this issue recently and what worked for me was adding the target name in firebase.json:

  "hosting": [
    {
      "target": "TARGET_NAME",
      ....
    }
  ]

Please note that this is a hotfix. I have not fully investigated the root cause, but it helped me to deploy the app when I needed it.

Indic answered 7/2, 2023 at 14:53 Comment(1)
I already specified the target under hosting but for me unfortunetly it didn't work.Burnette
C
0

There is no problem with your JSON file.

For deployment to firebase hosting first of all you have to build your project then you push your project to firebase hosting

command to build the project and deploy it to firebase

  1. For angular use the ng build command in the terminal of your project location.
  2. after building run the firebase deploy command
  3. See the Magic
Coessential answered 14/2, 2023 at 10:7 Comment(1)
yes, it worked yogesh. thanks for guiding me with the right steps.Burnette
E
0

Happened to me, the steps i made:

  1. DISCONNECTED THE WIFI then reconnect again
  2. re-auth using firebase login
  3. build your project
  4. run firebase deploy

everything worked properly

Engage answered 24/8, 2024 at 16:16 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.