This guide assumes the following:
In Heroku:
In your terminal:
heroku login
<APP_NAME>
with the name you provided or that was given to
you when creating the Heroku app.heroku git:remote --app <APP_NAME>
In your Blitz application:
start:production
and a build
command.
We'll call the start script in the Procfile
below. And Heroku will
run the build
script for you on deploy."scripts": {
+ "start:production": "blitz start --port $PORT",
+ "build": "blitz build"
}
Procfile
file inside the root of your project with the
following content.release: npx blitz prisma migrate deploy
web: npm run start:production
Deploy using git:
With these changes committed, to deploy your application, run:
git push heroku main
Once built you can open your application with the following command in your terminal
heroku open
Note: While the application should now be working you will not be able
to use authentication until you provide Heroku with a SESSION_SECRET_KEY
envivonment variable. You can do this with the following command replacing
<MY_SECRET>
with your secret (at least 32 characters long). On macOS and
Linux, you can generate it by running openssl rand -hex 16
in your
terminal.
heroku config:set SESSION_SECRET_KEY=<SESSION_SECRET_KEY>
On the free tier, Heroku does not supply you with SSL certificates. These are crucial for secure authentication, though - and Blitz' built-in authentication won't work without. You can use Cloudflare SSL to get free SSL certificates.