websocket request to durable object does not contain upgrade header

I have a weird issue. I deployed a project using durable objects to namespace.name.workers.dev and setup a worker route to a domain (ie. example.com) Everything works fine on the workers.dev domain, but when trying to connect to example.com it doesn't work with the error below. I've confirmed the browser is sending the header, but it's not being received by the fetch handler. Worker tried to return a WebSocket in a response to a request which did not contain the header "Upgrade: websocket"."
function handleApiRequest (request: Request, env: Env) {
const id = env.do.idFromName('default')
const roomObject = env.do.get(id)
return roomObject.fetch(request) // new Request(request.url, request) also does not work
}
function handleApiRequest (request: Request, env: Env) {
const id = env.do.idFromName('default')
const roomObject = env.do.get(id)
return roomObject.fetch(request) // new Request(request.url, request) also does not work
}
does anyone know why this isnt working?
6 Replies
Khafra
KhafraOP4mo ago
No description
No description
Chaika
Chaika4mo ago
In your website in Cloudflare, check under the "Network" tab if Websockets are enabled. Without websockets being enabled in CF, it strips the header.
Khafra
KhafraOP4mo ago
works perfectly, thank you! did I miss this in the docs somewhere?
Chaika
Chaika4mo ago
the network setting or what exactly? It's documented: https://developers.cloudflare.com/network/websockets/
Cloudflare Docs
WebSockets · Cloudflare Network settings docs
Cloudflare supports proxied WebSocket connections without additional configuration.
Khafra
KhafraOP4mo ago
under the durable objects docs, I would have never found the option
Chaika
Chaika4mo ago
oh idk, there's a few places in its docs where they are mentioned and the zone setting is only slightly related sometimes hard to place those things/for docs writers to remember everything. If you think it makes sense to have it in the docs at a specific spot under durable objects, you can make an issue or pr the docs repo in github
Want results from more Discord servers?
Add your server