Skip to content

fix(bundled-dev): reject requests to HMR patch files in non potentially trustworthy origins#22269

Merged
sapphi-red merged 2 commits intovitejs:mainfrom
sapphi-red:fix/reject-requests-to-hmr-patch-files-from-non-potentially-trust-worthy-origins
Apr 20, 2026
Merged

fix(bundled-dev): reject requests to HMR patch files in non potentially trustworthy origins#22269
sapphi-red merged 2 commits intovitejs:mainfrom
sapphi-red:fix/reject-requests-to-hmr-patch-files-from-non-potentially-trust-worthy-origins

Conversation

@sapphi-red
Copy link
Copy Markdown
Member

To avoid HMR patch files (that is used for full bundle mode) to be fetched from untrusted origins (like the other requests), there was a middleware to block those requests by checking Sec-Fetch-* headers. This did not work for non-potentially trustworthy origins because browsers doesn't send the headers for them.

This PR replaces that by ensuring an ESM syntax to exist in HMR patch files.

close #21849 (indirectly)

@sapphi-red sapphi-red added p2-edge-case Bug, but has workaround or limited in scope (priority) feat: bundled-dev labels Apr 20, 2026
@sapphi-red sapphi-red marked this pull request as ready for review April 20, 2026 03:22
@sapphi-red sapphi-red merged commit 868f141 into vitejs:main Apr 20, 2026
32 of 34 checks passed
@sapphi-red sapphi-red deleted the fix/reject-requests-to-hmr-patch-files-from-non-potentially-trust-worthy-origins branch April 20, 2026 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: bundled-dev p2-edge-case Bug, but has workaround or limited in scope (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vite 8 regression: cross-origin classic script request to /src/*.ts returns 403

1 participant