File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,24 @@ description: |
66Fresh provides built-in helpers for upgrading HTTP connections to WebSockets.
77There are two main approaches depending on your use case.
88
9+ > [ warn] : WebSocket upgrades do not work under the Vite dev server (`deno task
10+ > dev` ). Both ` app.ws()` and ` ctx.upgrade()` rely on ` Deno.upgradeWebSocket()`,
11+ > which requires Deno's native HTTP server to be handling the request. Vite
12+ > serves requests through a Node HTTP server and forwards them to Fresh as
13+ > synthesized ` Request ` objects, so the 101 upgrade response cannot be
14+ > completed and the ` open ` handler is never invoked.
15+ >
16+ > To test WebSocket endpoints locally, run a production-style build:
17+ >
18+ > ``` sh
19+ > deno task build && deno task start
20+ > ` ` `
21+ >
22+ > This runs ` deno serve` directly, so ` Deno.upgradeWebSocket()` works as
23+ > expected. If you need WebSockets during iterative development, run a
24+ > separate Deno entry point (e.g. ` deno serve -A main.ts` ) alongside Vite, or
25+ > host the WebSocket server as a sidecar on its own port.
26+
927# # Quick start with `app.ws()`
1028
1129The simplest way to add a WebSocket endpoint:
You can’t perform that action at this time.
0 commit comments