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!