Skip to content

Not work with Node.js v21 when using https in dev server #15495

@hronro

Description

@hronro

Describe the bug

The dev server always responds "Invalid request body"

The original issue can be found at sveltejs/kit#11213.

I believe the problem lies in the incompatibility between the vite dev server and HTTP/2, which is the default protocol when using HTTPS.

While many people only use HTTP on their dev servers to avoid this issue, we have specific cookie strategies that require both our dev server and production server to use HTTPS.

UPDATE: I recently upgraded to SvelteKit 2 (which is using Vite 5) and Node.js v21.5.0, the issue persists with a different error message:

TypeError: Headers.append: ":method" is an invalid header name.
    at webidl.errors.exception (node:internal/deps/undici/undici:1636:14)
    at webidl.errors.invalidArgument (node:internal/deps/undici/undici:1647:28)
    at appendHeader (node:internal/deps/undici/undici:2053:29)
    at fill (node:internal/deps/undici/undici:2039:11)
    at new Request (node:internal/deps/undici/undici:6151:13)

Reproduction

https://github.com/hronro/vite-https-issue

Steps to reproduce

  • Run pnpm i
  • Run pnpm dev
  • Open the page in browser

System Info

System:
    OS: Linux 6.6 Arch Linux
    CPU: (14) x64 AMD Ryzen 7 5800X 8-Core Processor
    Memory: 26.50 GB / 27.41 GB
    Container: Yes
    Shell: 3.7.0 - /usr/bin/fish
  Binaries:
    Node: 21.5.0 - /usr/bin/node
    Yarn: 1.22.21 - /usr/bin/yarn
    npm: 10.2.5 - /usr/bin/npm
    pnpm: 8.13.1 - /usr/bin/pnpm
  npmPackages:
    vite: ^5.0.10 => 5.0.10

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions