For testing Service Worker in local Windows machine, we need startup a https server: https://localhost:8080. Let’s do this job in 5 minutes.
Install chocolatey
Start PowerShell in administrator
and run following command.
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
See chocolatey manual: https://chocolatey.org/install
Install mkcert
choco install mkcert
Generate ssl cert for localhost
mkcert localhost
Startup https://localhost:8080 by http-server (nodejs is required)
npm i -g http-server
http-server ./ -S -K ./localhost-key.pem -C ./localhost.pem
That’s all
You can now access https://localhost:8080/
and test your Service Worker.
Example Project