Skip to content

Instantly share code, notes, and snippets.

@AbelVM
Created November 5, 2024 08:51
Show Gist options
  • Save AbelVM/ca529f74f0c6f0f3f35f8449e5ff36e5 to your computer and use it in GitHub Desktop.
Save AbelVM/ca529f74f0c6f0f3f35f8449e5ff36e5 to your computer and use it in GitHub Desktop.
Painless HTTPS in VSCode LiveView

Painless HTTPS in VSCode LiveView

Minimal setup in Debian flavoured Linux

  1. Install MKCert (actually, there's an official apt package available, so you can just apt install mkcert)
  2. Locate your VSCode User folder, usually at ~/.config/Code/{my_user_name}/
  3. Make a subfolder for your certificates ~/.config/Code/{my_user_name}/certs
  4. Create your certificates
mkcert \
  -key-file ~/.config/Code/{my_user_name}/certs/localhost-key.pem \
  -cert-file ~/.config/Code/{my_user_name}/certs/localhost-cert.pem \
  -install localhost 127.0.0.1
  1. Edit your user settings file at ~/.config/Code/{my_user_name}/settings.json, and add the following block
{
  
  ...
  
  "liveServer.settings.https": {
    "enable": true,
    "cert": "/home/{my_user_name}/.config/Code/User/certs/localhost-cert.pem",
    "key": "/home/{my_user_name}/.config/Code/User/certs/localhost-key.pem"
  }
}
  1. Restart VSCode
  2. Now, every time you open a LiveServer, it will be served through HTTPS

image

image

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