Header

{
host: 'localhost:8080',
connection: 'keep-alive',
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Mobile/15E148 Safari/604.1',
accept: 'application/json',
origin: 'http://localhost:5173',
'sec-fetch-site': 'same-site',
'sec-fetch-mode': 'cors',
'sec-fetch-dest': 'empty',
referer: 'http://localhost:5173/',
'accept-encoding': 'gzip, deflate, br, zstd',
'accept-language': 'en-US,en;q=0.9'
}

session: {
cookieCache: {
enabled: true,
maxAge: 20 * 60 * 60, // Cache duration in seconds
},
},

// The connection between the frontend and the backend.
app.use(cors({ origin: process.env.FRONTEND_URL, credentials: true }));

const session = await auth?.api?.getSession({
headers: fromNodeHeaders(req.headers),
});
console.log("sess", session);


These are every thing am getting session null in the server side express. js @Better Auth
Was this page helpful?