canastro
canastro
TTCTheo's Typesafe Cult
Created by canastro on 5/6/2024 in #questions
T3 - pass current tenant slug into TRPC context
i haven't done this yet, but I'll also update the user's cookie with the list of teams they belong too and their role. (just wont have the info of the current selected team in the cookie). This way I can also mitigate that issue without a complex query.
14 replies
TTCTheo's Typesafe Cult
Created by canastro on 5/6/2024 in #questions
T3 - pass current tenant slug into TRPC context
what do you mean? if someone puts a different team's slug in the url? my query ensures that the user is authorized to get that team's data
14 replies
TTCTheo's Typesafe Cult
Created by canastro on 5/6/2024 in #questions
T3 - pass current tenant slug into TRPC context
So far I'm being always getting the slug from the URL. in client components I add it to the headers in the TRPCReactProvider . in server components, instead of using the api that is statically created, I have to call a createAPI(slug) method  that creates the API and adds the slug to the headers. And then, finally, in the createContext I query the team data with the slug I get from the headers, and add it to the TRPC context.
14 replies
TTCTheo's Typesafe Cult
Created by canastro on 5/6/2024 in #questions
T3 - pass current tenant slug into TRPC context
yeah its the team's slug in the URL. you store it a cookie? when do you update it? on a GET request to the /[slug] layout? using session/cookies doesn't mean that a user can't use different "tenants" in separate tabs?
14 replies
TTCTheo's Typesafe Cult
Created by canastro on 5/6/2024 in #questions
T3 - pass current tenant slug into TRPC context
my only solution is to always create the api with the params.slug, but I wonder if theres a way to inject it via custom headers (as I do in the FE client)
14 replies