As assignment 3 comes to an end, just wanna share a few options for deploying the app which was built upon the create-react-app boilerplate.
These are mainly the options stated in the documentation, which makes use of the build folder generated with npm build script command. There’s heroku buildpacks, modulus, now and surge.sh, and probably more being added soon. These had been useful for deploying the frontend of the app, when our backend was not ready yet.
Deploying the backend comes with its own set of challenges. Before that, developing one to work with the webpack dev server was also a tough one, here’s a tutorial that came in useful for us. We eventually used Express for out backend, and it worked out quite well for us.
These were steps that worked from the discussion in the issues:
"react-scripts": "0.2.3"from devDependencies to dependencies
To tell npm to run server.js:
"start": "nf start -p 3000"with
"start": "node server.js"
Heroku runs npm install as default so to also run
npm i in our client build’s
"server": "API_PORT=3001 ./node_modules/.bin/babel-node server.jswith
"install": "cd client && npm install && npm run build && cd .."
To tell serve up the static site on the root domain:
const path = require('path');
var router = express.Router();
This is so that if I type in a direct url for example https://dropins.space/drops, I won’t get a 404.
It sucks that heroku puts dynos to sleep, but a simple workaround I googled was to do:
var https = require("https");
}, 300000); // ping every 5 minutes (300000)
So yea, check out dropins.space, and phew, time to start studying for midterms.