Skip to content

Instantly share code, notes, and snippets.

@tinovyatkin
Forked from Grawl/webpack-https-mkcert.md
Last active August 17, 2023 11:42
Show Gist options
  • Save tinovyatkin/e78d3d7f778fa7cfa93df36f0d462087 to your computer and use it in GitHub Desktop.
Save tinovyatkin/e78d3d7f778fa7cfa93df36f0d462087 to your computer and use it in GitHub Desktop.
Running Webpack Dev Server with HTTPS on developer machine using MKCERT
  1. Add local domain to /etc/hosts:

    127.0.0.1 my-project.dev

  2. Install mkcert

  3. Create certificate for this domain:

    ➜ mkcert my-project.dev
    
    Created a new certificate valid for the following names 📜
    - "my-project.dev"
    
    The certificate is at "./my-project.dev.pem" and the key at "./my-project.dev-key.pem"
  4. Add HTTPS options to Webpack Dev Server config:

    devServer: {
       host: 'my-project.dev',
       https: {
           key: './my-project.dev-key.pem',
           cert: './my-project.dev.pem',
       }
    },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment