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

why?
8 Replies
ThatBeanLady
ThatBeanLady10mo ago
should it not have the "upgrade" header
DaniFoldi
DaniFoldi10mo 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
ThatBeanLady10mo ago
so how might i handle that on the server side? not asking for code just a description if possible
DaniFoldi
DaniFoldi10mo 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
DaniFoldi10mo 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
ThatBeanLady10mo ago
actually i think i might need some code im a bit lost
DaniFoldi
DaniFoldi10mo ago
take a look at the tutorial I linked above, it has a complete example
ThatBeanLady
ThatBeanLady10mo 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