Search
Setup for Free
BA
Better Auth
•
8mo ago
Null
TRPC help
Hello
!
I have a trpc
.ts file that looks like
:
Better Auth
Join
9,564
Members
View on Discord
Similar Threads
Was this page helpful?
Yes
No
© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
N
Null
OP
•
5/19/25, 3:47 AM
message.txt
5.86KB
N
Null
OP
•
5/19/25, 3:47 AM
But when I try to call any protectedprocedure when logged
-in
, it gives the unauthorized error
.
N
Null
OP
•
5/19/25, 3:48 AM
Is it cause the headers is client side and the trpc can
't use it
?
C
coder2000
•
5/19/25, 4:10 AM
The headers come from your trpc route so no not really
. How are you setting the context in your route
?
C
coder2000
The headers come from your trpc route so no not really. How are you setting the ...
N
Null
OP
•
5/19/25, 4:28 AM
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
${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
"
)
;
}
}
)
,
C
coder2000
•
5/19/25, 12:33 PM
Yes
, but how do you actually call the
createTRPCContext
createTRPCContext
function in your route with the headers
?
${API_BASE_URL}/api/example
${API_BASE_URL}/api/example
createTRPCContext
createTRPCContext
Similar Threads
trpc
BA
Better Auth / help
8mo ago
TRPC support
BA
Better Auth / help
8mo ago
Turborepo + trpc setup
BA
Better Auth / help
11mo ago
Better Auth with tRPC
BA
Better Auth / help
8mo ago