From e37269376d915c943bd9073081ad2ab3d1c0da1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Tue, 12 Jul 2022 14:30:00 +0900 Subject: [PATCH] fix: reload on restart with middleware mode (fixes #9038) (#9040) --- packages/vite/src/client/client.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/client/client.ts b/packages/vite/src/client/client.ts index cee0e1e9f066ea..350b2f537d139c 100644 --- a/packages/vite/src/client/client.ts +++ b/packages/vite/src/client/client.ts @@ -294,7 +294,8 @@ async function waitForSuccessfulPing(hostAndPath: string, ms = 1000) { try { // A fetch on a websocket URL will return a successful promise with status 400, // but will reject a networking error. - await fetch(`${location.protocol}//${hostAndPath}`) + // When running on middleware mode, it returns status 426, and an cors error happens if mode is not no-cors + await fetch(`${location.protocol}//${hostAndPath}`, { mode: 'no-cors' }) break } catch (e) { // wait ms before attempting to ping again