Elysia backend + Nextjs frontend, getSession issue

import { headers } from "next/headers";

import { authClient } from '@/lib/auth';

export default async function Home() {
  const hdrs = await headers();
  const sess = await authClient.getSession({
    fetchOptions: {
      headers: await headers(),
    }
  })
  console.log("Session:", sess);

  return (
    <main className="flex min-h-[calc(100dvh-68px)] flex-col items-center ">
      ///
      <pre>
        {JSON.stringify(sess, null, 2)}
        {JSON.stringify(hdrs, null, 2)}
      </pre>
    </main>
  );
}


the getSession result is
{
  "data": null,
  "error": {
    "status": 404,
    "statusText": "Not Found"
  }
}

even though the headers has a proper cookie after login

my backend is elysiajs at port 3000 and frontend is nextjs at 3001. the other methods like, login and signup work (they're being called client side, not through server actions)
image.png
Was this page helpful?