CertMon

FRONTEND TOOLING

How to set up HTTPS in Vite local dev without certificate errors

Configuring HTTPS in Vite is straightforward, but plugins like @vitejs/plugin-basic-ssl generate untrusted self-signed certificates that trigger browser warnings and kill Hot Module Replacement (HMR).

Start in Terminal: Manual Vite HTTPS configuration

If you have a trusted local CA, export the certificate and key, then configure vite.config.ts:

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import fs from 'node:fs'

export default defineConfig({
  plugins: [react()],
  server: {
    https: {
      key: fs.readFileSync('./certs/vite.key'),
      cert: fs.readFileSync('./certs/vite.crt'),
    },
    host: 'web.myapp.test',
    port: 5173,
    hmr: {
      protocol: 'wss',
      host: 'web.myapp.test',
      clientPort: 443,
    }
  }
})

Why basic-ssl causes problems

The standard recommendation in many tutorials is to install @vitejs/plugin-basic-ssl. However:

The zero-config solution: CertMon

With CertMon, you don't need to configure SSL in Vite at all! Keep your Vite dev server running on plain HTTP on port 5173 (or let CertMon auto-discover it).

CertMon's built-in reverse proxy terminates trusted HTTPS on https://web.myapp.test (port 443) and automatically forwards HTTP requests and WebSocket HMR messages to Vite without any config changes.

CertMon proxy routing Vite server to .test domain with full WebSocket HMR support.
CertMon terminates TLS on port 443 and proxies to Vite on 5173 with seamless HMR.

Download CertMon free trial

Related guides