Hello Everyone!
One of the best ways to host Gather projects on a server for free (or really affordably) is to do so on Heroku. I’ve heard lots of questions during office hours with @opalrose and she asked me to write up a post that would help to explain the process.
Here is my attempt to provide some basic steps to get your code hosted and running on Heroku:
-
Create a new app on Heroku by clicking on the “New” button dropdown in the top right corner
-
Name your app and click “Create app”
-
Click on the “Deploy” tab and choose your “Deployment method”
-
In this guide, I’m choosing Github
a. If you don’t have a Git repository setup yet, then navigate to www.github.com and create one
i. Upload your files
1) Make sure you’ve specified your API_KEY, SPACE_ID, and MAP_ID in your config
ii. Be sure to include express in your package.json
iii. Here’s a helpful doc on installing express and what to include: How to deploy your app to the web using Express.js and Heroku
iv. TLDR express code required:
const express = require(“express”);
const app = express();
// use alternate localhost and the port Heroku assigns to $PORT
const host = ‘0.0.0.0’;
const port = process.env.PORT || 3000;app.listen(port, host, function() { console.log("Server started......."); });
-
Search for your GitHub Repo in the “Connect to GitHub” section and click “Connect”
-
Choose to “Enable Automatic Deploys” or just go ahead and “Deploy Branch”
Click on “More” => “View Logs” to watch everything spin up successfully!
Good luck and hope it helps! Looking forward to seeing all of the cool projects you serve on Heroku!