This commit also forces the environment into HTTPS when in production.
This commit is too large to list all changes.