Search
Star
Feedback
Setup for Free
© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
Hono RPC session not in request - Better Auth
BA
Better Auth
•
12mo ago
•
1 reply
Kevin
Hono RPC session not in request
When i use the RPC with hono client
. Session not defined
BACKEND
const app
= new Hono
<honoVariables
>
(
)
.use
(
"
"
,
cors
(
{
origin
:
"
http://localhost:5173
"
,
allowHeaders
:
[
"Content
-Type
"
,
"Authorization
"
]
,
allowMethods
:
[
"POST
"
,
"GET
"
,
"OPTIONS
"
]
,
exposeHeaders
:
[
"Content
-Length
"
]
,
maxAge
: 600
,
credentials
: true
,
}
)
)
.use
(
"
"
, async
(c
, next
)
=
>
{
const session
= await auth
.api
.getSession
(
{ headers
: c
.req
.raw
.headers
}
)
;
if
(
!session
)
{
c
.set
(
"user
"
, null
)
;
c
.set
(
"session
"
, null
)
;
return next
(
)
;
}
c
.set
(
"user
"
, session
.user
)
;
c
.set
(
"session
"
, session
.session
)
;
return next
(
)
;
}
)
.on
(
[
"POST
"
,
"GET
"
]
,
"
/api
/auth
/
*
"
,
(c
)
=
>
{
return auth
.handler
(c
.req
.raw
)
;
}
)
SESSION NOT DEFINED
const api
= hc
<AppType
>
(import
.meta
.env
.VITE
_BACKEND
_URL
+
'
/
'
)
const response
= await api
.room
.
$get
(
)
SESSION DEFINED
const response
= await fetch
(
/rooms
/rooms
,
{credentials
: true
}
)
Better Auth
Join
9,988
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Similar Threads
Was this page helpful?
Yes
No
Similar Threads
Hono session caching
BA
Better Auth / help
3mo ago
Next Hono session is empty
BA
Better Auth / help
9mo ago
Is it safe to check the user session only in middleware and not in routes in Hono?
BA
Better Auth / help
7mo ago