Instead of having to use PM2 to run two separate Node processes, we can use Webpack to package frontend application code into a single index.html which receives all requests. Typically this means that compiled code is optimised + HMR is turned off.
Normally you would do npm run build on the server, but since the server doesn't have a lot of RAM, you have to do npm run tar:staging && npm run deploy:staging in order to build + deploy.
Instead of usinghttps with the cert and key signed by CloudFlare, I set up LetsEncrypt (currently only on the staging server), plus auto-renewal.
By right, the backend should also be serving on http rather than https, but I haven't done it here (not familiar enough with Node/Express).
eslint
This is to standardize code style on the frontend. All errors (there were a lot) have been resolved (some were suppressed), while warnings have yet to be fixed.
Fixes #121, #116, #114.
Webpack
Instead of having to use PM2 to run two separate Node processes, we can use Webpack to package frontend application code into a single
index.html
which receives all requests. Typically this means that compiled code is optimised + HMR is turned off.Normally you would do
npm run build
on the server, but since the server doesn't have a lot of RAM, you have to donpm run tar:staging && npm run deploy:staging
in order to build + deploy.Nginx
API server is now reachable at https://staging.exchangebuddy.com/api/, rather than an arbitrary port. Also serves the Webpack files.
LetsEncrypt
Instead of using
https
with the cert and key signed by CloudFlare, I set up LetsEncrypt (currently only on the staging server), plus auto-renewal.By right, the backend should also be serving on
http
rather thanhttps
, but I haven't done it here (not familiar enough with Node/Express).eslint
This is to standardize code style on the frontend. All errors (there were a lot) have been resolved (some were suppressed), while warnings have yet to be fixed.
Do check if I accidentally broke anything in the process on the staging server at https://staging.exchangebuddy.com/.
I think the Webpack configuration can be optimised further, but can settle that next time.
If this is alright, I will merge and carry out with the migration of the production server early morning tomorrow (6 Dec, after 2am).