Skip to content

Vite's dev server returns 404 if the request does not contain an Accept header #9520

@ghost91-

Description

@ghost91-

Describe the bug

When making a request to Vite's dev server without adding the Accept header, the server always returns a 404. According to RFC 7231, the Accept header is optional:

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

For that reason, I would expect Vite's dev server to just respond regularly if the Accept header is missing.

I am running into this problem when trying to use Playwright with Vite. Playwright has functionality to run a command to start the server (just calling vite, basically, in this case), and then polls the server URL until it receives a successful response. However, it performs the HTTP requests with a simple http.get (http from Node.js), and does not include an Accept header, so Vite's dev server always responds with a 404 and playwright runs into a timeout waiting for the server.

Reproduction

https://github.com/ghost91-/vite-dev-server-problem

System Info

System:
    OS: Linux 5.18 Arch Linux
    CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
    Memory: 23.20 GB / 31.10 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.15.1 - /run/user/1000/fnm_multishells/8953_1659556049790/bin/node
    npm: 8.13.2 - /run/user/1000/fnm_multishells/8953_1659556049790/bin/npm
  Browsers:
    Chromium: 103.0.5060.134
    Firefox: 103.0.1

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestp2-nice-to-haveNot breaking anything but nice to have (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions