-
-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(trpc): allow to pass custom headers to trpc client #441
Conversation
A tRPCHeaders signal is exposed to set/get the headers added to each tRPC call. This allows us to, e.g. add an authorization header that we can then use to create protected procedures that can only be executed when the user is authorized. closes #394
✅ Deploy Preview for analog-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for analog-blog ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for analog-app ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
@brandonroberts @Dafnik @markostanimirovic please take a look at the |
@goetzrobin its worth a look. I don't think we need to build an abstraction on top of tRPC configuration if we give them direct access to configure it already. If we don't maybe we should consider that first and not make this too Angular-specific. |
Hey guys 👋 I think that function composition would not bring many benefits in this case. SignalStore APIs are designed in a composable way mostly to allow building features that can be reused in multiple stores, overcome limitations of the class-based state mgmt solutions, and enable tree-shaking of unused stuff. In the case of the |
Yeah I might have jumped ahead to some premature optimization on that one. I was just trying to think ahead of we'd ever allow for a Web-socket link and all that. Maybe the way to go is what you suggested @brandonroberts: to expose more of the config directly |
Its less for you to maintain in the long run 🙂 |
A tRPCHeaders signal is exposed to set/get the headers added to each tRPC call. This allows us to, e.g. add an authorization header that we can then use to create protected procedures that can only be executed when the user is authorized.
closes #394
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Which package are you modifying?
What is the current behavior?
Closes #394
What is the new behavior?
You can provide custom headers to the trpc client by setting the tRPCHeaders signal
Does this PR introduce a breaking change?
Other information
It works but I feel like the way we configure the tRPC client could be much better.
I think we should aim for a way to configure the tRPC client like @markostanimirovic allows the ngrx signal store to be configured. I want to get this merged because it is essential for anyone who wants to use the client for anything that is
not public and the DX is alright but we should definitely rethink the way we allow people to configure the tRPC client.
[optional] What gif best describes this PR or how it makes you feel?