flutter - Dealing with Firebase hosting issues - Stack Overflow

admin2025-04-17  3

I have a flutter web app that I used firebase for its database, authentication and deployment, but whenever I deploy I only see this screen. this is the firebase.json file

{
  "database": {
    "rules": "database.rules.json"
  },
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

Has anyone faced this problem before? I tried to change the Firebase project and it didn't make a difference

I have a flutter web app that I used firebase for its database, authentication and deployment, but whenever I deploy I only see this screen. this is the firebase.json file

{
  "database": {
    "rules": "database.rules.json"
  },
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

Has anyone faced this problem before? I tried to change the Firebase project and it didn't make a difference

Share Improve this question edited Feb 6 at 2:51 Marco 3782 silver badges10 bronze badges asked Jan 30 at 19:04 Ali HossamAli Hossam 11 bronze badge 4
  • This is a very common problem. Is your built web content going into the "public" folder as indicated by your firebase.json? By default, that folder contains the web content shown in your screenshot. – Doug Stevenson Commented Jan 30 at 19:27
  • Also posted on: reddit.com/r/Firebase/comments/1idptnr/firebase_hosting_issue – Frank van Puffelen Commented Jan 30 at 19:31
  • As @DougStevenson has said, check which folder you are using for your "public" folder. I experienced the same issue while deploying a react app onto firebase; spent 4 hours and then figured that I set the public folder to "public" instead of "dist" (where my code was) in the firebase init. – Gleb Commented Jan 31 at 1:12
  • when you are hosting firebase cli asked you that 'index.html file already exist do you want to overwrite it ?' and you said 'yes'. because of this your index.html code is changed by firebase. – raghav042 Commented Feb 6 at 5:04
Add a comment  | 

1 Answer 1

Reset to default 0

It looks like this is an issue with how your hosting.public is configured. In Flutter, your built web application is located in build/web folder. Since the hosting.public attribute specifies which directory to deploy to Firebase Hosting(reference), you have to set it's value to where your Flutter web application build is located.

Update your firebase.json to something like:

{
  "database": {
    "rules": "database.rules.json"
  },
  "hosting": {
    "public": "build/web",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}
转载请注明原文地址:http://www.anycun.com/QandA/1744896179a89154.html