When I create a new WebSocket it sends a request with the get method

why?
8 Replies
ThatBeanLady
ThatBeanLadyOP12mo ago
should it not have the "upgrade" header
DaniFoldi
DaniFoldi12mo ago
The way websockets work is by first sending a http GET request to the provided endpoint, which can then be upgraded by the server if the upgrade: websocket header is sent - along with some other websocket-related headers
ThatBeanLady
ThatBeanLadyOP12mo ago
so how might i handle that on the server side? not asking for code just a description if possible
DaniFoldi
DaniFoldi12mo ago
Using the WebSockets API · Cloudflare Workers docs
WebSockets allow you to communicate in real time with your Cloudflare Workers serverless functions. In this guide, you will learn the basics of …
DaniFoldi
DaniFoldi12mo ago
well in a worker, you need to tell the runtime to create a websocket connection, terminate one side within the runtime and send back the other one to the client
ThatBeanLady
ThatBeanLadyOP12mo ago
actually i think i might need some code im a bit lost
DaniFoldi
DaniFoldi12mo ago
take a look at the tutorial I linked above, it has a complete example
ThatBeanLady
ThatBeanLadyOP12mo ago
yeah i tried implementing that but it didnt like it it says that it has an invalid upgrade header the upgrade header is just websocket though @PurpleBlob ? thank you
Want results from more Discord servers?
Add your server