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('*/*') )