Describe the bug
Vite 8 dev server returns 403 Forbidden for cross-origin classic script requests to /src/*.ts files, while the same setup works in Vite 7.3 and in rolldown-vite.
This was reproduced with a minimal setup using only the vanilla-ts template.
Reproduction setup:
- Project A: plain Vite
vanilla-ts app
- Project B: plain Vite
vanilla-ts app
- Project A loads a source file from Project B using a classic script tag:
<script src="http://localhost:5174/src/counter.ts"></script>
Observed behavior:
- If Project B uses
vite@7.3.x, the script loads correctly
- If Project B uses
vite@8.x, the request returns 403 Forbidden
- If Project B uses
rolldown-vite, it also works correctly
Additional notes:
- The failure only happens when the file is loaded via
<script src="..."> from a different origin. Directly opening the same URL in the browser works.
- This does not appear to be a Rolldown issue, because the same reproduction works with
rolldown-vite.
Reproduction
https://github.com/Denis6902/vite8-cross-origin-script-403-repro
Steps to reproduce
- Create two separate Vite projects using the
vanilla-ts template
- Run Project A on one port, for example
5173
- Run Project B on another port, for example
5174
- In Project A, add this to
index.html:
<script src="http://localhost:5174/src/counter.ts"></script>
- Start both dev servers
- Open Project A in the browser
System Info
System:
OS: Windows 11 10.0.26200
CPU: (16) x64 Intel(R) Core(TM) i5-14400
Memory: 9.91 GB / 31.77 GB
Binaries:
Node: 22.22.0 - C:\nvm4w\nodejs\node.EXE
npm: 10.9.4 - C:\nvm4w\nodejs\npm.CMD
Browsers:
Chrome: 145.0.7632.160
Edge: Chromium (145.0.3800.58)
npmPackages:
vite: ^8.0.0 => 8.0.0
Used Package Manager
npm
Logs
No response
Validations
Describe the bug
Vite 8 dev server returns
403 Forbiddenfor cross-origin classic script requests to/src/*.tsfiles, while the same setup works in Vite 7.3 and inrolldown-vite.This was reproduced with a minimal setup using only the
vanilla-tstemplate.Reproduction setup:
vanilla-tsappvanilla-tsappObserved behavior:
vite@7.3.x, the script loads correctlyvite@8.x, the request returns403 Forbiddenrolldown-vite, it also works correctlyAdditional notes:
<script src="...">from a different origin. Directly opening the same URL in the browser works.rolldown-vite.Reproduction
https://github.com/Denis6902/vite8-cross-origin-script-403-repro
Steps to reproduce
vanilla-tstemplate51735174index.html:System Info
System: OS: Windows 11 10.0.26200 CPU: (16) x64 Intel(R) Core(TM) i5-14400 Memory: 9.91 GB / 31.77 GB Binaries: Node: 22.22.0 - C:\nvm4w\nodejs\node.EXE npm: 10.9.4 - C:\nvm4w\nodejs\npm.CMD Browsers: Chrome: 145.0.7632.160 Edge: Chromium (145.0.3800.58) npmPackages: vite: ^8.0.0 => 8.0.0Used Package Manager
npm
Logs
No response
Validations