Next.js Discord

Discord Forum

How to secure a Websocket sever in client component

Unanswered
Rock Sandpiper posted this in #help-forum
Open in Discord
Rock SandpiperOP
I have a client component that connects to a websocket server. Right now there's no authorization or anything. What would be ways of handling this, as if someone were to get the websocket server's URL they would just be able to connect to it

2 Replies

Exactly the same as securing a typical http api. You send a token as part of the header/requests and verify it on the server
For example you could use jwts and verify that the one received by the websocket server is valid