Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1529

How to deploy a react app in production over https?

$
0
0

I have a React App that works beautifully over HTTPS using a .env.production file containing:

HTTPS=trueSSL_CRT_FILE=/etc/ssl/certs/mycert.crtSSL_KEY_FILE=/etc/ssl/private/mykey.key

the package.json file contains:

"scripts": {"start": "env-cmd -f .env.production react-scripts start","build:production": "env-cmd -f .env.production react-scripts build"}

when I do:

npm start

everything works, and I can access my server over HTTPS from anywhere. Now, this is the funny thing, now I do:

npm run build:production

which also works fine, and I get:

The build folder is ready to be deployed.You may serve it with a static server:serve -s build

Now, this is what fails:

1) When I use the serve command above, the environment variables in the .env.production file are not picked up! Why?

2) If I pass the environment variables manually as in:

HTTPS=true SSL_CRT_FILE=/etc/ssl/certs/mycert.crt SSL_KEY_FILE=/etc/ssl/private/mykey.key PORT=8580 serve -s build 

Only the PORT variable seems to be picked up, but the server now runs on HTTP. Any ideas why?!


Viewing all articles
Browse latest Browse all 1529

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>