Deploying To Heroku πŸš€

Install Heroku CLI

The Heroku Command Line Interface (CLI) makes it easy to create and manage your Heroku apps directly from the terminal. It’s an essential part of using Heroku.

macOS

brew tap heroku/brew && brew install heroku

Windows

Download the appropriate installer for your Windows installation.

Ubuntu 16+

Run the following from your terminal:

sudo snap install --classic heroku

Verifying installation

To verify your CLI installation, use the heroku --version command:

heroku --version

Getting started

After you install the CLI, run the heroku login command. You’ll be prompted to enter any key to go to your web browser to complete login. The CLI will then log you in automatically.

heroku login

Troubleshooting

If you’re having issues with the CLI, first ensure that you’re using the latest version. If you’re not, try updating with heroku update.

Production build

Heroku will now enter the client directory and create the production build of the React app for us.

Deploying is as easy as running the following commands:

git init
git add .
git commit -m "Initial commit"
heroku create
git push heroku master

Heroku is smart enough to detect that we are also running a node server, it will create it automatically.

Confirm Installation

heroku status

Managing config vars

Make sure that you add your ENV variables inside Heroku.

The heroku config commands of the Heroku CLI makes it easy to manage your app’s config vars.

You can also edit/add config vars from your app’s Settings tab in the Heroku Dashboard.

Add custom domain

You probably want to have a custom domain for your store. If that's the case, you can add a domain from Heroku dashboard.

Settup SSL in Heroku

And with a couple of clicks, you can also add SSL certificate.

Heroku Error

You might get this error when deploying to Heroku: Invalid Host header. If that's the case, there's several ways to approach this:

Resource: