Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: run htmlFallbackMiddleware for no accept header requests #15025

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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