Hi, we're using Nextjs and would like to do per-pa...
# talk-kratos
w
Hi, we're using Nextjs and would like to do per-page authentication (check the session for every page). The actual nextjs docs on authemtication https://nextjs.org/docs/authentication#other-providers actually link to this ory example: https://github.com/vercel/examples/tree/main/solutions/auth-with-ory but it only shows how to do login/signup and all the other actions, and does not show an example for subsequent request authentication. Is there an example for this?
l
👋 what we planned to do what to call the session/whoami endpoint on each page and see if the session is valid, otherwise you're redirected to the login page
w
do you think this is enough?
l
I do, either your session is valid and it's ok, or you will get a http error code because it's expired
w
I see, sounds good, thanks!
@loud-spoon-23770 do you have any idea what the method is on the js client? I can't find a whoami method 😞
l
I think it was
ory.toSession()
w
But its description states
Copy code
Set the Session Token when calling from non-browser clients. A session token has a format of `MP2YWEMeM8MxjkGKpH4dqOQ4Q4DlSPaj`.
keyword being non-browser 😕
l