I followed the guide at https://hono.dev/docs/getting-started/cloudflare-pages
and then added websockets following https://hono.dev/docs/helpers/websocket
see repo here: https://github.com/benjamine/hono-vite-websocket (made to reproduce this)
websocket never connects when running the vite dev server (I think because there's never a server upgrade).
websocket works correclty when using vite build+preview or when deployed to cloudflare.
reproduction steps:
- clone the repo
- npm i && npm run dev
- check the console or network tab, note that the browser's websocket never connects
I noticed connection succeeds adding an upgrade handler at the vite plugin
configureServer(server) {
...
server.httpServer?.on("upgrade", (request, socket, head) => {
...
// handle this similarly to hono-node/ws ?
and confirmed that makes the connecting succeed (but this might not be the right way or place to handle it).
I followed the guide at https://hono.dev/docs/getting-started/cloudflare-pages
and then added websockets following https://hono.dev/docs/helpers/websocket
see repo here: https://github.com/benjamine/hono-vite-websocket (made to reproduce this)
websocket never connects when running the vite dev server (I think because there's never a server upgrade).
websocket works correclty when using vite build+preview or when deployed to cloudflare.
reproduction steps:
I noticed connection succeeds adding an upgrade handler at the vite plugin
and confirmed that makes the connecting succeed (but this might not be the right way or place to handle it).