feat: Authentication by Websocket
Problem
Describe the feature you'd like to request We know that websocket do not use http headers, but during handshake http request can be used. Page 14 RFC 6455 https://www.rfc-editor.org/rfc/rfc6455#page-14 Current implementation sending these headers [code block] But I would like to add my custom headers here, eg Authorization. Connected reddit topic of other user: https://www.reddit.com/r/node/comments/117fgb5/trpc_correct_way_to_authorize_websocket/ Describe the solution you'd like to see This problem was solved in apollo client by [code block] in issue https://github.com/apollographql/apollo-client/issues/3967 or even better [code block] Probably when this function will return new headers (eg new bearer token will be added) we probably need restart all operations. [code block] so it seems to be complicated. Describe alternate solutions Alternatively we can think about `onOpen` function in `createWSClient` or if it is called after handshake, then maybe add function `beforeOpen` and give end user control over connecting and reconnecting when headers will be changed. Additional information I can try to contribute with this but need to know if this feature will be accepted and how to design it. ๐จโ๐งโ๐ฆ Contributing - [X] ๐โโ๏ธ Yes, I'd be down to file a PR implementing this feature! I wrote article about approaches to this problem, so you can read details and discuss here which one should be preferred as official, and maybe instead of this feature we will ad
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: feat: Authentication by Websocket
This feature would prove exceptionally valuable and impressive, particularly if it includes built-in support for managing refresh tokens. Its utility would be evident in single-page applications (SPAs) or across various mobile and desktop applications, thereby broadening the reach and application of tRPC.
Trust Score
3 verifications
- 1
This feature would prove exceptionally valuable and impressive, particularly if
This feature would prove exceptionally valuable and impressive, particularly if it includes built-in support for managing refresh tokens. Its utility would be evident in single-page applications (SPAs) or across various mobile and desktop applications, thereby broadening the reach and application of tRPC.
Validation
Resolved in trpc/trpc GitHub issue #3955. Community reactions: 2 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep