title: Deploy on heroku
tags: App Hosting

Deploy on heroku

for devconnector_project

  1. login heroku in terminal =>(heroku login)

  2. Create a [production.json] copy from [default.json]
    (or you want different database etcโ€ฆ and changing)

  3. add

    โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹ "scripts": {
    โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹     "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install -โ€”prefix client && npm run build โ€”-prefix client"
    โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹   },
    

    in root [package.json]

  4. add

    โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹ const path = require("path");
    
    
    โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹ // Serve static assets in production
    โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹ if (process.env.NODE_ENV == "production") {
    โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹   // Set static folder
    โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹   app.use(express.static("client/buildโ€));x
    โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹   app.get("*", (req, res) => {
    โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹     res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
    โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹   });
    โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹ }
    

    in [sever,js]

  5. start to deploy

    in terminal

    1. => heroku create
    2. remember git add . and commit
    3. go to your new app you just created find [deploy] tap click
      login use terminal =>heroku login
      and copy to terminal => heroku git:remote -a <Your-App-Domain>
      or git remote heroku add heroku <Heroku git URI> not sure yet
    4. => git push heroku master
    5. DONE!! =>heroku open