Troubleshooting Null User Session in Hono Node Backend with Next.js Frontend

I’m experiencing an issue with retrieving user session data in my web application using Hono backend and Next.js frontend. Despite having a middleware that can access session information, my client-side route returns a null session.

Problem Details

  • Backend Framework: Hono with Node.js
  • Authentication Library: Better-auth
  • Frontend: Next.js

Debugging Steps Taken

  • Configured Axios with withCredentials: true
  • Enabled secure cookies
  • Ran Next.js with experimental HTTPS

Observed Behavior

  • Middleware logs show valid session data
  • /user/session endpoint returns null
  • /api/auth/get-session endpoint works correctly

Sample Configuration

// Axios instance configuration
const axiosInstance = axios.create({
  baseURL: SERVER_DOMAIN,
  withCredentials: true
});

Any insights into why the session retrieval is failing would be greatly appreciated!

check ur cors settings n make sure ur cookies r bein sent correctly. mayb try debuggin with browser dev tools to c whats goin on w/ ur requests. seems lyk a config issue tbh

hmm, looks lyk u might need 2 check ur middleware logic more closely. have u tried loggin the exact path of session data n seein if theres a mismatch btw backend n frontend? wondering if its a routing prblm :thinking: