devtools icon indicating copy to clipboard operation
devtools copied to clipboard

WebSocket connection fails when user's Vite config has server.https enabled

Open fvarano opened this issue 8 months ago • 0 comments

Describe the bug

When using the standalone devtools server (e.g., via npm run analyze with @vitejs/devtools), the client gets stuck on the "Vite DevTools needs Authorization" screen if the user's Vite config includes server.https (commonly set by plugins like @vitejs/plugin-basic-ssl).

Probable Cause:

The standalone devtools server inherits server.https from the user's resolved Vite config and creates a WSS (secure WebSocket) server, but the HTTP page served on port 9999 uses plain HTTP. This causes a protocol mismatch:

The devtools HTTP server runs at http://localhost:9999 The WebSocket server reads viteConfig.server.https and creates a WSS server on port 7812 The client at http://localhost:9999 tries to connect via ws://localhost:7812 (plain WebSocket) Connection is refused because the server expects wss:// The requestTrust() RPC call fails silently leaving the client stuck on the auth prompt

Reproduction

https://github.com/fvarano/devtools-ssl-repro

System Info

System:
    OS: Linux 6.6 Ubuntu 25.10 25.10 (Questing Quokka) on WSL
    CPU: (16) x64 AMD Ryzen 9 5900HX with Radeon Graphics
    Memory: 13.27 GB / 15.55 GB
    Container: Yes
    Shell: 5.2.37 - /bin/bash
  Binaries:
    Node: 24.14.0 - /run/user/1000/fnm_multishells/125097_1774951296734/bin/node
    npm: 11.9.0 - /run/user/1000/fnm_multishells/125097_1774951296734/bin/npm
    pnpm: 10.30.3 - /home/david/.local/share/pnpm/pnpm
    bun: 1.3.9 - /snap/bin/bun

Used Package Manager

npm

Validations

  • [x] Follow our Code of Conduct
  • [x] Read the Contributing Guide.
  • [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • [x] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • [x] The provided reproduction is a minimal reproducible of the bug.

fvarano avatar Mar 31 '26 10:03 fvarano