Skip to content

Commit

Permalink
fix: run htmlFallbackMiddleware for no accept header requests (#15025)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Nov 17, 2023
1 parent 78b34e0 commit b93dfe3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/vite/src/node/server/middlewares/htmlFallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('*/*')
)
Expand Down

0 comments on commit b93dfe3

Please sign in to comment.