How access 'env' in the WebSockets Template
Hey, I've got a Cloudflare Worker that implements WebSocket connection. The implementation is from: https://github.com/cloudflare/websocket-template
I am wondering how can I access the
env
variable that is usually available to us when we use the syntax instead of the one used in the template, 5 Replies
I want to access
env
so I can access MY_KV_NAMESPACE
You'll want to convert the old syntax to not use the old service worker one
I've tried but I can't get it to work.
I hope I am wrong but I think you can't use the new syntax because its a WebSocket connection
so if you define it with, the new syntax
it won't work as expected because, from the client-side when you invoke
websocket.send()
, I don't think that will invoke the fetch on the WorkerI believe it should.
hmm, you're right, it seems to be working - awaiting further confirmation lol