From b93dfe3e08f56cafe2e549efd80285a12a3dc2f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Sat, 18 Nov 2023 03:57:37 +0900 Subject: [PATCH] fix: run htmlFallbackMiddleware for no accept header requests (#15025) --- packages/vite/src/node/server/middlewares/htmlFallback.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/node/server/middlewares/htmlFallback.ts b/packages/vite/src/node/server/middlewares/htmlFallback.ts index de29c54ec321eb..d5f053fd34211c 100644 --- a/packages/vite/src/node/server/middlewares/htmlFallback.ts +++ b/packages/vite/src/node/server/middlewares/htmlFallback.ts @@ -14,13 +14,11 @@ export function htmlFallbackMiddleware( if ( // Only accept GET or HEAD (req.method !== 'GET' && req.method !== 'HEAD') || - // Require Accept header - !req.headers || - typeof req.headers.accept !== 'string' || // Ignore JSON requests - req.headers.accept.includes('application/json') || + req.headers.accept?.includes('application/json') || // Require Accept: text/html or */* !( + req.headers.accept === undefined || // equivalent to `Accept: */*` req.headers.accept.includes('text/html') || req.headers.accept.includes('*/*') )