From a747966fbb0c9e99d8f204e0ea221f108e143d6a Mon Sep 17 00:00:00 2001 From: Frederik Rothenberger Date: Thu, 26 Oct 2023 14:54:31 +0200 Subject: [PATCH] Add option to run dev server using TLS This PR introduces the env variable `TLS_DEV_SERVER` that can be set to `1` to enable the dev server serving content using tls. --- package.json | 1 + vite.config.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/package.json b/package.json index bb71982cd1..24b075e2ab 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "@types/ua-parser-js": "^0.7.36", "@typescript-eslint/eslint-plugin": "6.7.5", "@typescript-eslint/parser": "6.7.5", + "@vitejs/plugin-basic-ssl": "^1.0.1", "@wdio/globals": "^8.6.9", "astro": "^2.4.1", "eslint": "8.51.0", diff --git a/vite.config.ts b/vite.config.ts index 8c1183dd60..7300fcf70b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,3 +1,4 @@ +import basicSsl from "@vitejs/plugin-basic-ssl"; import { resolve } from "path"; import { AliasOptions, defineConfig, UserConfig } from "vite"; import { @@ -58,6 +59,7 @@ export default defineConfig(({ mode }: UserConfig): UserConfig => { plugins: [ [...(mode === "development" ? [injectCanisterIdPlugin()] : [])], [...(mode === "production" ? [minifyHTML(), compression()] : [])], + [...(process.env.TLS_DEV_SERVER === "1" ? [basicSsl()] : [])], ], optimizeDeps: { esbuildOptions: { @@ -67,6 +69,7 @@ export default defineConfig(({ mode }: UserConfig): UserConfig => { }, }, server: { + https: process.env.TLS_DEV_SERVER === "1", proxy: { "/api": "http://127.0.0.1:4943", },