vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.95k stars 6.23k forks source link

Dev server will return index when file not exists #18107

Closed tocque closed 2 months ago

tocque commented 2 months ago

Describe the bug

request a not existed file will receive /index.html.

Reproduction

https://stackblitz.com/edit/vitejs-vite-vlvqcb?file=index.html&terminal=dev

Steps to reproduce

just visit https://vitejsvitevlvqcb-s5sf--5173--28a8ce1b.local-corp.webcontainer.io/aaa.js

System Info

System:
    OS: Windows 11 10.0.22635
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
    Memory: 2.30 GB / 15.84 GB
  Binaries:
    Node: 22.3.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.8.1 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.7.1 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.8)
    Internet Explorer: 11.0.22621.3566
  npmPackages:
    @vitejs/plugin-react: ^4.3.1 => 4.3.1 
    vite: ^5.4.5 => 5.4.5

Used Package Manager

pnpm

Logs

No response

Validations

stackblitz[bot] commented 2 months ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

hi-ogawa commented 2 months ago

I would assume this is how SPA fallback works normally https://vitejs.dev/config/shared-options.html#apptype For example, you can configure appType: "mpa" to avoid such fallback https://stackblitz.com/edit/vitejs-vite-gfcunr?file=vite.config.ts

sapphi-red commented 2 months ago

Yep, this is an expected behavior.