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

vite 5 preview return 404 on / if Accept Header is missing #15022

Closed
7 tasks done
StefanSchoof opened this issue Nov 17, 2023 · 4 comments · Fixed by #15025 or #15059
Closed
7 tasks done

vite 5 preview return 404 on / if Accept Header is missing #15022

StefanSchoof opened this issue Nov 17, 2023 · 4 comments · Fixed by #15025 or #15059

Comments

@StefanSchoof
Copy link

StefanSchoof commented Nov 17, 2023

Describe the bug

  1. Start vite preview
  2. Request / with Accept Header gives a 200 and the index.html
    grafik
  3. Request / without Accept Header gives a 404 and a empty body
    grafik

This is a changed behavior to vite 4.

This lead to that npx wait-on http://localhost:4173 will never finish and blocks. Which is also used in https://github.com/cypress-io/github-action#wait-on. The workaround is to use npx wait-on http://localhost:4173/index.html

If I read the rfc right this behavior is also not according to https://www.rfc-editor.org/rfc/rfc7231#section-5.3.2

A request without any Accept header field implies that the user agent
will accept any media type in response.

The minimal reproduction is only a new project with npm create vite@latest

Reproduction

https://github.com/StefanSchoof/vite-empty-accept

Steps to reproduce

  1. npm run build
  2. npm run preview

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 6.43 GB / 31.73 GB
  Binaries:
    Node: 20.9.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.1.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.3636.0), Chromium (119.0.2151.58)
    Internet Explorer: 11.0.19041.3636
  npmPackages:
    vite: ^5.0.0 => 5.0.0

Used Package Manager

npm

Logs

No response

Validations

@StefanSchoof
Copy link
Author

Thanks @sapphi-red , that was quick.

@titenis
Copy link

titenis commented Nov 21, 2023

Is this really fixed? Still getting errors:

yarn vite preview & yarn wait-on http://localhost:4173 --verbose
[1] 3940
  ➜  Local:   http://localhost:4173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
waiting for 1 resources: http://localhost:4173
making HTTP(S) head request to  url:http://localhost:4173 ...
  HTTP(S) error for http://localhost:4173 AxiosError: Request failed with status code 404

@patak-dev
Copy link
Member

@titenis the fix was released a few hours ago in v5.0.1, please check that you have that version. If it is still failing, please create a new issue with a minimal repro (maybe you hit another issue)

@sapphi-red
Copy link
Member

I reproduced it. I should have tested with wait-on as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants