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
You can edit your package.json scripts section to read:
"scripts": {
"start": "set HTTPS=true&&react-scripts start",
...
}
or just run set HTTPS=true&&npm start
Just a sidenote, for me, making this change breaks hot reloading for some reason....
-- Note: OS === Windows 10 64-Bit
I could not get that to work (setting HTTPS=true), instead, i used
react-https-redirect
A simple wrapper around your App
component.
I am using Windows 10 latest build with Windows Insider Program till this date.
It seems like there are three cases while using Windows 10:
set HTTPS=true&&npm start
set HTTPS=true&&npm start
HTTPS=true npm start
Documentation: Create react app dev
Edit your package.json file and change the starting scripts for starting your secures domain. for example https
{
"name": "social-login",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-facebook-login": "^4.0.1",
"react-google-login": "^3.2.1",
"react-scripts": "1.1.4"
},
"scripts": {
// update this line "start": "HTTPS=true react-scripts start",
"start": "set HTTPS=true&&react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
thanks
might need to Install self-signed CA chain on both server and browser. Difference between self-signed CA and self-signed certificate
I think it is worth to mention to set PORT=443
, default HTTPS
standard port.
You can avoid to attach :PORT
at the end of the address every time.
My package.json
is like (tested from Ubuntu Server 18.04):
{
...
"scripts": {
"start": "HTTPS=true PORT=443 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
...
}