I was wondering if anyone knows how to use https on dev for the \'create-react-app\' environment. I can\'t see anything about that in the README or quick googling. I just wa
I`m using Windows 10 and I had the same issue. I realized that you need to:
set HTTPS=true&&npm start
You can also put this code into your package.json file under the scripts section like this:
"scripts": {
"start": "set HTTPS=true&&react-scripts start",
(...)
}
Bonus: If you want to change the PORT use this command insted:
set HTTPS=true&&set PORT=443&&react-scripts start
Obs.: Pay attention to the blank spaces NOT left in between some characters.
You can browse this link for more detais.
Please use this in command prompt
set HTTPS=true&&npm start
To avoid untrusted certificate errors in Chrome and Safari you should manually specify a self-signed key pair. CRA allows you to specify them.
Also, use .env
file to store these vars.
On macOS, just add your certificate to Keychain Access and then set Trust Always
in its details.
You can also create a file called .env in the root of your project, then write
HTTPS=true
After that, just run "npm start" as you usually do to start your app.
Docs: https://facebook.github.io/create-react-app/docs/advanced-configuration
Works both on Linux and Windows, unlike some other answers posted here.
In Case of MAC/UNIX do
export HTTPS=true
npm start
Or simple one liner
export HTTPS=true&&npm start
Or update start script in package.json to
"start": "export HTTPS=true&&PORT=3000 react-scripts start",
you should be able to hit https.
In Windows environment add following lines to package.json:
"scripts": {
"start-dev": "set HTTPS=true&&set PORT=443&&react-scripts start"
},
It will start development server with https and port 443. At the present moment NodeJs have known bug to run this correctly but it worked with nodeJs v8.11.3 - https://nodejs.org/dist/v8.11.3/node-v8.11.3-x64.msi for me.