Hello folks,
Just created the nextjs-aut0 example app based on the steps in the readme here: GitHub - auth0/nextjs-auth0: Next.js SDK for signing in with Auth0
Now when I’m not logged in, it still calls the auth/me route and I get a 401. Is there a better way to check if I’m logged in without actually trying to read user data and responding with a 401?
Thank you so much!
Which SDK this is regarding: @auth0 /nextjs-auth0
SDK Version: 1.9.1
Platform Version: “next”: “12.2.0”, “react”: “18.2.0”,
Code Snippets/Error Messages/Supporting Details/Screenshots:
2 Likes
jack6
October 11, 2022, 9:35pm
4
did u find a solution for this ?
tyf
October 11, 2022, 10:46pm
6
Hey all! For future reference please see:
Hey there @jack6 !
This is expected behavior - The front end uses /api/auth/me endpoint to check if the user is authenticated or not (401 = logged out, 200 = logged in). You could technically adjust the profile handler to not return 401, but this would also require you to write your own front end code to get the user sessions since the useUser hook expects that API to respond with a 401 if the user is unauthenticated.
Given this has surfaced multiple times already, I definitely recommend creati…
system
Closed
October 25, 2022, 10:47pm
7
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.