May 23, 2020 • ☕️ 1 min read
日本語

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.

run-powershell-admin.png

Copy
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

Copy
choco install mkcert

Generate ssl cert for localhost

Copy
mkcert localhost

Startup https://localhost:8080 by http-server (nodejs is required)

Copy
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

https://github.com/thundermiracle/try-scheduled-push


Relative Posts

Easy HTTPS Setup in Next.js! A Guide to Custom Domain Support

September 3, 2024

ThunderMiracle

Blog part of ThunderMiracle.com