From 167753d3754507430600a1bc2b100ca321b17a86 Mon Sep 17 00:00:00 2001 From: Thomas Scholtes Date: Wed, 4 Jan 2023 17:10:12 +0100 Subject: [PATCH] fix(hmr): base default protocol on client source location (#11497) --- packages/vite/src/client/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/client/client.ts b/packages/vite/src/client/client.ts index b010298116d25e..6e63c4fa526072 100644 --- a/packages/vite/src/client/client.ts +++ b/packages/vite/src/client/client.ts @@ -23,7 +23,7 @@ const importMetaUrl = new URL(import.meta.url) // use server configuration, then fallback to inference const serverHost = __SERVER_HOST__ const socketProtocol = - __HMR_PROTOCOL__ || (location.protocol === 'https:' ? 'wss' : 'ws') + __HMR_PROTOCOL__ || (importMetaUrl.protocol === 'https:' ? 'wss' : 'ws') const hmrPort = __HMR_PORT__ const socketHost = `${__HMR_HOSTNAME__ || importMetaUrl.hostname}:${ hmrPort || importMetaUrl.port