Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to run HTTPS locally #430

Closed
adrice727 opened this issue Aug 12, 2016 · 17 comments
Closed

Add option to run HTTPS locally #430

adrice727 opened this issue Aug 12, 2016 · 17 comments
Milestone

Comments

@adrice727
Copy link

I work on a lot of projects that involve screen sharing via WebRTC which must be done over https. I currently have no way of testing locally. Would it be possible to add an option to run https on the local webpack dev server?

@zet4
Copy link

zet4 commented Aug 13, 2016

What I did is run Caddy proxy which redirects to dev server and could do https.
But it would be nice yea.

@mxstbr
Copy link
Contributor

mxstbr commented Aug 13, 2016

How would one go about doing that?

@zet4
Copy link

zet4 commented Aug 13, 2016

run caddy with something like

0.0.0.0:8080
proxy / localhost:3000
tls self_signed # or provide cert key

@vutran
Copy link

vutran commented Aug 15, 2016

I think this is a great idea and can also be expanded and added to the deployment scripts as well. Perhaps using something like certbot can be of use.

@zet4
Copy link

zet4 commented Aug 15, 2016

@vutran
Certbot uses LE, LE requires a domain AFAIK.
Also LE is meant for deployment/production, not development.
All you want is self signed cert.

@bripkens
Copy link

I build a tool for this purpose called proxrox. You can use it to start proxies with autogenerated self-signed certificates, combine origins and a few other things. The repo also contains an example project with a sever and client part (webpack based).

@dceddia
Copy link
Contributor

dceddia commented Aug 22, 2016

Is it sufficient to just turn on HTTPS for the webpack dev server?

With the change below, It starts up with a self-signed cert, and I'm proxying requests to my backend HTTPS server with the "proxy" option from 0.3.0. I needed to turn this on because my XSRF token header wasn't being sent.

Inside react-scripts/scripts/start.js, add the https: true:

function runDevServer(port) {
  var devServer = new WebpackDevServer(compiler, {
    https: true,
    // ...
  });

I just hacked it up directly inside node_modules to see if it'd work, but now I'm thinking I'll need to eject it to make it all work properly. This HTTPS change introduces a bug where npm start still opens up a browser to http://localhost:3000 instead of https://localhost:3000, so that would need to change as well.

I could turn this into a PR if that makes sense.

@gaearon
Copy link
Contributor

gaearon commented Aug 24, 2016

Marking this with a milestone so I don’t forget to take another look at it.

@gaearon gaearon modified the milestones: 0.4.0, 0.3.0 Sep 1, 2016
@gaearon
Copy link
Contributor

gaearon commented Sep 2, 2016

@dceddia Can you please turn 26877bcaa71509be3350f546f215f0855dc77ba1 into a PR? The only change I’d make is to have it look at process.env.HTTPS instead, similar to how we read process.env.PORT.

@dceddia
Copy link
Contributor

dceddia commented Sep 2, 2016

I like that idea. I'll work on a PR.

dceddia added a commit to dceddia/create-react-app that referenced this issue Sep 2, 2016
With the HTTPS env var set 'true', the dev server will serve over HTTPS.
@dceddia
Copy link
Contributor

dceddia commented Sep 2, 2016

@gaearon I created a PR with 3e52607 (ignore that other one).

gaearon pushed a commit that referenced this issue Sep 2, 2016
With the HTTPS env var set 'true', the dev server will serve over HTTPS.
@gaearon
Copy link
Contributor

gaearon commented Sep 2, 2016

Fixed by #430.

@gaearon gaearon closed this as completed Sep 2, 2016
@gaearon
Copy link
Contributor

gaearon commented Sep 2, 2016

HTTPS=true env variable is honored in 0.4.0.
See the release notes!

stayradiated pushed a commit to stayradiated/create-react-app that referenced this issue Sep 7, 2016
With the HTTPS env var set 'true', the dev server will serve over HTTPS.
feiqitian pushed a commit to feiqitian/create-react-app that referenced this issue Oct 25, 2016
With the HTTPS env var set 'true', the dev server will serve over HTTPS.
@sshadmand
Copy link

Works on Chrome, but in FF

localhost:3000 uses an invalid security certificate. The certificate is not trusted because it is self-signed. Error code: SEC_ERROR_UNKNOWN_ISSUER

Is there a way to choose a cert I create?

@jadbox
Copy link

jadbox commented Aug 2, 2018

I too need a way of using my own cert for local development. This is especially required for developing authentication systems locally, using DDNS.

@mmccartney
Copy link

Under the covers react-scripts start is using webpack-dev-server which generates and stores a self-signed cert under node_modules/webpack-dev-server/ssl. You should be able to replace files there as you see fit.

As for Safari, I'm finding that if I click on Show Details then there is a link at the end that says visit this website. When you click that, it will trust the cert. I haven't tried this long enough but the code I see for webpack-dev-server makes me think the cert is only good for 30 days after which it regenerates. I suspect you'll have to re-trust it every 30 days.

Hope this helps!

@conatus
Copy link

conatus commented Jan 8, 2019

It would be useful to use mkcert to use Let's Encrypt to serve up a real SSL certificate here.

Though this might more appropriately be a responsiblilty for webpack-dev-server?

@lock lock bot locked and limited conversation to collaborators Jan 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests