Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 1.28 KB

using-https-in-development.md

File metadata and controls

44 lines (30 loc) · 1.28 KB
id title sidebar_label
using-https-in-development
Using HTTPS in Development
HTTPS in Development

Note: this feature is available with [email protected] and higher.

You may require the dev server to serve pages over HTTPS. One particular case where this could be useful is when using the "proxy" feature to proxy requests to an API server when that API server is itself serving HTTPS.

To do this, set the HTTPS environment variable to true, then start the dev server as usual with npm start:

Windows (cmd.exe)

set HTTPS=true&&npm start

(Note: the lack of whitespace is intentional.)

Windows (Powershell)

($env:HTTPS = "true") -and (npm start)

Linux, macOS (Bash)

HTTPS=true npm start

Note that the server will use a self-signed certificate, so your web browser will almost definitely display a warning upon accessing the page.

To avoid having to set the environment variable each time, you can either include in the npm start script like so:

{
  "start": "HTTPS=true react-scripts start"
}

Or you can create a .env file with HTTPS=true set. Learn more about environment variables in CRA.