Cross Domain : Receiving null for both data and error while fetching session

I have a nextjs frontend and a hono backend both hosted in ec2 instance through docker. While logging in the cookies are being passed and stored in the browser, but after loging in the user is redirected to dashboard page where i use
const {data,error} = await authClient.getSession({fetchOption : { header : await headers()}})
const {data,error} = await authClient.getSession({fetchOption : { header : await headers()}})
To check active session , i am getting null for both data and error and is redirected back to login. Note : this setup works fine locally. Also it works fine when the login route is called to the localserver and all other to the hosted server. I have enabled the cookies to be samesite none , partitioned, httpOnly everything
5 Replies
aswnss
aswnssOP4mo ago
Is there any additional thing i am forgetting in nextjs to get the headers in production ?
nikatune
nikatune4mo ago
can you send auth config
aswnss
aswnssOP4mo ago
This is the auth.ts file from hono
aswnss
aswnssOP4mo ago
I suspect that in production nextjs is not sending cookies
sebastian
sebastian4mo ago
try disabling the crosssubdomain cookies as this could be a blocker double check if the cookies have the samesite set to none and secure to true (the cookie passed in production)

Did you find this page helpful?