Dogs Chasing Squirrels

A software development blog

Monthly Archives: May 2023

Svelte HTTPS on localhost – vite edition

0

In a previous post, I showed how to enable HTTP on Svelte, back before Svelte had switched over to Vite. Now, on Vite:

First, generate a certificate and key. Save these as certificate.crt and certificate.key in the project’s folder.

Next, edit vite.config.ts. Add the following to the top:

import fs from 'fs';

Then, in the server configuration:

    server: {
        https: {
            key: fs.readFileSync('certificate.key'),
            cert: fs.readFileSync('certificate.crt'),
        }
    },