0

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:

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?

Awan-23
  • 11
  • 1
  • 2
  • Have you set a redirect on your http web server so that all http requests go through https. Then you can remove your javascript middleware/redirects so that the http redirects are handled by the web server first (you could still have sails middleware/policies as a second layer). – Anthony Sep 19 '20 at 04:14
  • @Anthony, by web server do you mean the react UI, or the sails server? How can I get either of them to listen for http requests? Only https requests seem to be reaching them. – Awan-23 Sep 24 '20 at 12:48
  • Gave up trying to have port :84 serve both HTTP and HTTPS requests. Changed main port to be :94 serving HTTPS, and added a listener on :84 to redirect to :94. – Awan-23 Oct 09 '20 at 13:58

0 Answers0