Skip to content

Instantly share code, notes, and snippets.

@nighttiger1990
Last active November 8, 2023 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nighttiger1990/99bd38f783c88488e6219602863f36f5 to your computer and use it in GitHub Desktop.
Save nighttiger1990/99bd38f783c88488e6219602863f36f5 to your computer and use it in GitHub Desktop.
Https in reactjs with dotnet dev-certs

Requirement

Export cert and key file using dotnet dev-certs

dotnet dev-certs https --format PEM -np -ep '<filepath-with-pem-extensions>'
# example: dotnet dev-certs https --format PEM -np -ep D:\ssl\localhost.pem

Note: with -np parameter (mean no-password in dev-certs tool) will export 2 file localhost.pem and localhost.key like above exam

Setting reactjs project

Create .env at root react project

HTTPS="true"
SSL_KEY_FILE="<path-to-keyfile>/localhost.key"
SSL_CRT_FILE="<path-to-cert-file>/localhost.pem"

Run project

yarn start

or

react-scripts start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment