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, {credentials: true})
Was this page helpful?