Open PowerShell as administrator
Install Chocolatey
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Install mkcert
choco install mkcert
Still from PowerShell, create certificates for i.e: local.dev
domain name
mkcert local.dev 127.0.0.1 ::1
you should get this output in terminal:
Created a new certificate valid for the following names π
- "local.dev"
- "127.0.0.1"
- "::1"
The certificate is at "./local.dev+2.pem" and the key at "./local.dev+2-key.pem" β
It will expire on 31 January 2027 π
PS: ls
to find the two generated CA certificate files in that current directory. Usually in: C:\Users\YOUR_USER_NAME\
Add the following to C:\Windows\System32\drivers\etc\hosts
using i.e: notepad
(Run as administrator)
# Local development (HTTPS, SSL mkcert)
127.0.0.1 local.dev
::1 local.dev
-
Run from your project directory run:
npm init -y # if not already initialized npm i express # Install Express server
-
open
package.json
, add:"type": "module"
and also add under"scripts": {
the following:"dev": "node --env-file=.env --watch index.js"
-
Copy the minimal server configuration
index.js
(provided below) to your project root directory. -
Do the same with the
.env
file (provided below), and add the needed environment values. -
Run
npm run dev
-
Open in browser: https://local.dev (β notice the HTTPS protocol!).
You should finally see a"Hello, HTTPS!"
message.