Handle authentication for WebSocket in SvelteKit? #2764
winston0410
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a REST server that implemented WebSocket. A notification will be published from the server through socket, when any of the resources is changed(i.e. POST, PUT, DELETE).
Cookie that stores JWT might be a solution here. So from browser you send a request to the endpoints of sveltekit, which will then handshake with the server with WebSocket enabled, but I guess it cannot pass back the upgraded connection to the browser.
Another approach I have in my might be connecting to the server with socket directly from client of sveltekit, bypassing its backend, and verify the connection by the jwt token stored in cookie.
What do you think about these two approaches?
Beta Was this translation helpful? Give feedback.
All reactions