diff --git a/src/client/client.ts b/src/client/client.ts index 3e784a2c3d56ad..8f312e969f819f 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -50,8 +50,7 @@ console.log('[vite] connecting...') declare var __VUE_HMR_RUNTIME__: HMRRuntime -const socketProtocol = location.protocol === 'https:' ? 'wss' : 'ws' -const socket = new WebSocket(`${socketProtocol}://${location.host}`) +const socket = new WebSocket(`ws://${location.hostname}:24678`) function warnFailedFetch(err: Error, path: string | string[]) { if (!err.message.match('fetch')) { @@ -140,12 +139,9 @@ socket.addEventListener('message', async ({ data }) => { socket.addEventListener('close', () => { console.log(`[vite] server connection lost. polling for restart...`) setInterval(() => { - new WebSocket(`${socketProtocol}://${location.host}`).addEventListener( - 'open', - () => { - location.reload() - } - ) + new WebSocket(`ws://${location.host}`).addEventListener('open', () => { + location.reload() + }) }, 1000) }) diff --git a/src/node/server/index.ts b/src/node/server/index.ts index 31aa8f84cf7b77..42ac4b05806de7 100644 --- a/src/node/server/index.ts +++ b/src/node/server/index.ts @@ -116,7 +116,7 @@ function resolveServer( requestListener: RequestListener ) { if (https) { - return require('https').createServer( + return require('http2').createSecureServer( resolveHttpsConfig(httpsOption), requestListener ) diff --git a/src/node/server/serverPluginHmr.ts b/src/node/server/serverPluginHmr.ts index ea2bce051fa5bd..85ae708a8d36db 100644 --- a/src/node/server/serverPluginHmr.ts +++ b/src/node/server/serverPluginHmr.ts @@ -114,7 +114,7 @@ export const hmrPlugin: ServerPlugin = ({ }) // start a websocket server to send hmr notifications to the client - const wss = new WebSocket.Server({ server }) + const wss = new WebSocket.Server({ port: 24678 }) wss.on('connection', (socket) => { debugHmr('ws client connected')