Current state: Depending on the npm start
script, my web app is accessible by at the http://
address, or the https://
address, but not both.
Goal: I'd like the app to run on https://
, and for any http://
requests to be redirected to https://
.
App info: The web app is created with Sails for the server, and create-react-app
for the UI. To run locally, I use two terminals to start each up (server on :1337
, UI on :3000
). To run in prod, I build the UI and copy the build into the server folder, then start the server on :84
(:80
already taken).
What I've tried:
- I've tried adding redirection on the Sails server by adding middleware and policies.
- I've tried adding redirection on the UI by adding a script in the HTML header, checking for
window.location.protocol
inindex.js
, adding to the http-proxy-middleware, and using react-https-redirect.
In all cases, I'm able to access the app if I go to the https://
address, but get err_empty_response
from the http://
one. None of my http://
requests seem to even reach the app or server.
I've heard that using NGINX as a load-balancer may solve this, but I'm hoping for a solution that doesn't require as much set up. Any suggestions?