Home > other >  Procedure uploading a web-app to Firebase
Procedure uploading a web-app to Firebase

Time:11-07

Though I have set up several web apps on Firebase in the past. This time I am having problems uploading this one to the server.

The special thing about this app is that I am using React.

I followed this tutorial, did the following to get started in the terminal:

$ npx create-react-app myapp
$ cd myapp/
$ npm install firebase --save
$ npm start

And then after spending much time working on the React side of things to get something close enough to my taste, at this point I can see the app running, on port 3000 (http://localhost:3000/), in the browser as I expect. It is also accessing a Realtime database on the sever as I want. The next step is for me to have the app itself run on the server and not only on my localhost as it is now. What do I need to do for that? I have made a few trials based on my previous experience with Firebase, running "firebase deploy" ( some other things), but it is not working. The app is not on the server. More precisely, it shows a white page.

As a complementary piece of information, this is my firebase.json file:

{
  "database": {
    "rules": "database.rules.json"
  },
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}

And this is how the public directory looks:

...$ ls public/
404.html    index.html  logo512.png robots.txt
favicon.ico logo192.png manifest.json
...$ 

CodePudding user response:

You must build your React app (npm run build or your build command) and then make sure that public directory in firebase.json is your build folder.

{
  "hosting": {
    "public": "build", // name of build output directory
  }
}

In your case it was set to public and hence that directory was being deployed.

  • Related