Next Hono session is empty
I do not know how to structure this question to be honest, But is there a way to get the session details or another way to check if the user is logged in ? if the frontend and backend is hosted on seperate server ( ie: auth.ts file is not available at next frontend side).
in the image:
Login is working , register user is working
What i need
get the session details of the logged in user.
Some template projects i saw in github uses hono as a replacement to next api route. That is not what i want . I want the hono to be a seperate server.
in the image:
- backend is the hono application
- users is the frontend nextjs application
Login is working , register user is working
What i need
get the session details of the logged in user.
Some template projects i saw in github uses hono as a replacement to next api route. That is not what i want . I want the hono to be a seperate server.


Solution
So to digest the issue was I was logging in from a server component which did not set the cookies in the nextjs application.
which would not be a problem if I was using hono as a replacement of the next api router, where nextCookies() plugin could be helping while the logging was happening from a server component.
but in my case i am not replacing the next router .. i am having a seperate hono server so i guess the plugin nextCookies would not reflect to the next server
What fixed :
when i made the login request from a client component nextjs will automatically set the cookies when the header contains a set cookie value
Why it did not work previously:
The cors setting was needed to be added in the hono side which i did not do
which would not be a problem if I was using hono as a replacement of the next api router, where nextCookies() plugin could be helping while the logging was happening from a server component.
but in my case i am not replacing the next router .. i am having a seperate hono server so i guess the plugin nextCookies would not reflect to the next server
What fixed :
when i made the login request from a client component nextjs will automatically set the cookies when the header contains a set cookie value
Why it did not work previously:
The cors setting was needed to be added in the hono side which i did not do
