Dhravya / cloudflare-saas-stack

Quickly make and deploy full-stack apps with database, auth, styling, storage etc. figured out for you. Add all primitives you want.
3.09k stars 231 forks source link

[Auth] The session is always null in the API running with Preview #47

Open koraniar opened 1 month ago

koraniar commented 1 month ago

I am not sure if this issue belongs to this repo but any help is appreciated, the issue seems to happen only in Preview, running in prod and in dev is working well. It does not allow me to access the current session information in the API side

I cloned the project and modified the file src/app/api/hello/route.ts by this way to return the current session:

import { auth } from "@/server/auth";
import type { NextRequest } from 'next/server'

export const runtime = 'edge'

export async function GET(request: NextRequest) {
  const session = await auth();

  return Response.json({ session });
}

When I start the project using bun run dev, and after I login and access http://localhost:3000/api/hello I can get the current session: {"session":{"user":{"name":"Esteban",....."expires":"2024-10-24T20:50:42.270Z"}}

But when I do the same starting the project using bun run preview and accessing http://localhost:8788/api/hello it always return empty: {"session":null}

DebasisOnDev commented 3 weeks ago

Hey do you figured out something for this?