TRPC help

Hello! I have a trpc.ts file that looks like:
5 Replies
Null
NullOP7d ago
Null
NullOP7d ago
But when I try to call any protectedprocedure when logged-in, it gives the unauthorized error. Is it cause the headers is client side and the trpc can't use it?
coder2000
coder20007d ago
The headers come from your trpc route so no not really. How are you setting the context in your route?
Null
NullOP7d ago
the context code is here already i just call protectedprocedure getMe: protectedProcedure .query(async ({ ctx }) => { try { const response = await axios.get( ${API_BASE_URL}/api/example, { headers: { "X-API-Key": ctx.dbUser.apiKey }, } ); const user = response.data as UserInDB; return { ...user, discordId: user.discord_id?.toString?.() ?? user.discord_id, }; } catch (error) { handleApiError(error, "getMe"); } }),
coder2000
coder20006d ago
Yes, but how do you actually call the createTRPCContext function in your route with the headers?

Did you find this page helpful?