session returning null

Hi guys,

Question. I have implemented better-auth into my express.js server and I got it working with email and password (sign-up/in) but when it comes to getting a session I get a status code of 200 but a null in return.

Basically just followed the docs on installation and under integration of Express. But is there some headers object that I need to catch to get the session or have I missed a step?

app.get("/api/me", async (req, res) => {
  try {
    const session = await auth.api.getSession({
      headers: fromNodeHeaders(req.headers),
    });
    res.json(session);
  } catch (e) {
    res.status(500).json({ error: "Failed to get session" });
  }
});
image.png
Was this page helpful?