# Nextjs-auth0 - 401 Error when not logged in?

**URL:** <https://community.auth0.com/t/nextjs-auth0-401-error-when-not-logged-in/86311>\
**Category:** Get Help\
**Created:** [July 2, 2022, 11:50am UTC](https://community.auth0.com/t/nextjs-auth0-401-error-when-not-logged-in/86311 "2022-07-02T11:50:48Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [October 11, 2022, 10:46pm UTC](https://community.auth0.com/t/nextjs-auth0-401-error-when-not-logged-in/86311/6 "2022-10-11T22:46:48Z")

</div>

Hey all! For future reference please see:

> [@401 Unauthorized issue at /api/auth/me!](https://community.auth0.com/t/401-unauthorized-issue-at-api-auth-me/89761/5):
>
> 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…

---

_[View the full topic](https://community.auth0.com/t/nextjs-auth0-401-error-when-not-logged-in/86311)._
