fix(dev): apply server headers to 404 responses (fix #22543)#22544
Open
sjh9714 wants to merge 1 commit into
Open
fix(dev): apply server headers to 404 responses (fix #22543)#22544sjh9714 wants to merge 1 commit into
sjh9714 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #22543.
server.headerswas applied by built-in asset, HTML, and transform response paths, but not by the dev server fallthrough 404 path. This adds a lightweight headers middleware after CORS and host validation so POST/API-style 404 responses include configured server headers too.Changes
server.headersbefore user and built-in response middlewares run.Testing
pnpm install --frozen-lockfilepnpm --filter=./packages/vite run build-bundlepnpm test-unit packages/vite/src/node/__tests__/dev.spec.tspnpm exec eslint --cache --concurrency auto packages/vite/src/node/server/index.ts packages/vite/src/node/__tests__/dev.spec.tspnpm --filter=./packages/vite run build-types-rollpnpm --filter=./packages/vite run typecheckgit diff --checkpnpm exec oxfmt --check packages/vite/src/node/server/index.ts packages/vite/src/node/__tests__/dev.spec.tsNote: I used Codex while preparing this change, reviewed the final diff, and ran the listed checks locally.