# Http://localhost:3000/api/auth/me returns 404 in Console

**URL:** <https://community.auth0.com/t/http-localhost-3000-api-auth-me-returns-404-in-console/82831>\
**Category:** Get Help\
**Tags:** api, login, nextjs, auth0\
**Created:** [May 4, 2022, 1:46am UTC](https://community.auth0.com/t/http-localhost-3000-api-auth-me-returns-404-in-console/82831 "2022-05-04T01:46:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![wisenickel5](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/wisenickel5/32/37076_2.png) [@wisenickel5](https://community.auth0.com/u/wisenickel5)\
**Post date:** [May 4, 2022, 1:46am UTC](https://community.auth0.com/t/http-localhost-3000-api-auth-me-returns-404-in-console/82831/1 "2022-05-04T01:46:57Z")

</div>

Greetings, I have just gone through the following [tutorial](https://auth0.com/blog/ultimate-guide-nextjs-authentication-auth0/PCqVdU2k47CuOxc2yx2CsLqivhrYA/quickstart/nextjs) to get my Next.js App integrated with Auth0.  
I am able to log in and log out just fine but when trying to display user information on the page after login, the user is always null. I have made sure to follow every step in the tutorial exactly and the page that I am trying to display user data on looks like this:

```plaintext
import { useUser } from "@auth0/nextjs-auth0";
import Layout from "../components/layout";

export default function Profile({ ...props }) {
  const { user, error, isLoading } = useUser();

  if (isLoading) return <div>Loading...</div>;
  if (error) return <div>{error.message}</div>;

  if (user) {
	  return (
		  <Layout>
		    <div>
			  Welcome {user.name}! <a href="my-site/api/auth/logout">Logout</a>
		    </div>
		  </Layout>
	  )
  }
  return <a href="/api/auth/login" className="secondary-navbar-btn">Login</a>;
}

```

Again, I can log in through Auth0 just fine, but cant get the user object to return properly. After further inspection I noticed that I get an error in the browser console that reads: `Failed to Load Resource ... 404 Not Found: http://localhost:3000/api/auth/me`.

From my understanding, this url is related to getting the user’s profile. What can I do to fix this?

---

<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:** [May 4, 2022, 11:49pm UTC](https://community.auth0.com/t/http-localhost-3000-api-auth-me-returns-404-in-console/82831/4 "2022-05-04T23:49:53Z")

</div>

Hey there @wisenickel5 welcome to the community!

> [@wisenickel5](#):
>
> From my understanding, this url is related to getting the user’s profile. What can I do to fix this?

I’m not super familiar with this particular SDK/blog (they’re on my list!) so it’s tough to know exactly what could be going on here - I can however confirm that the sample app that is a companion to our Next.js SDK Quickstart documentation functions as expected. I am able to authenticate a user and utilize another route to display profile information. Perhaps you could give that a look?

For reference, both the quickstart and sample app can be found here:

[https://auth0.com/docs/quickstart/webapp/nextjs](https://auth0.com/docs/quickstart/webapp/nextjs)

> <https://github.com/auth0-samples/auth0-nextjs-samples/tree/main/Sample-01>
>
> //github.com/auth0-samples/auth0-nextjs-samples/tree/main/Sample-01

Hope this helps!

---

<div class="post-metadata">

**Author:** ![wisenickel5](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/wisenickel5/32/37076_2.png) [@wisenickel5](https://community.auth0.com/u/wisenickel5)\
**Post date:** [May 6, 2022, 2:36am UTC](https://community.auth0.com/t/http-localhost-3000-api-auth-me-returns-404-in-console/82831/5 "2022-05-06T02:36:13Z")

</div>

Hi @ty.frith thank you for your response!  
The tutorial you linked was actually the first tutorial I used to configure Auth0 in to my app.  
I have triple checked my .env.local, my application settings on [mange.auth0.com](http://mange.auth0.com), and the profile.js file that returns the user object. I also went through the sample application’s repo and used the same profile.js that they used.

The same thing keeps happening though, after I log in, I get errors in the browser console saying that the `user` object cannot be returned and that the [https://localhost:3000/api/auth/me](https://localhost:3000/api/auth/me) url cannot be found.

I am willing to schedule a quick zoom call so that we can take a closer look at what is going on!

---

<div class="post-metadata">

**Author:** ![wisenickel5](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/wisenickel5/32/37076_2.png) [@wisenickel5](https://community.auth0.com/u/wisenickel5)\
**Post date:** [May 6, 2022, 1:50pm UTC](https://community.auth0.com/t/http-localhost-3000-api-auth-me-returns-404-in-console/82831/6 "2022-05-06T13:50:56Z")

</div>

@ty.frith One other thing to note that might be giving me some trouble with this issue:

- In my next.config.js I have reset the basepath to `/my_path`. My next.config.js looks something like this:

```plaintext
module.exports = {
  basePath: '/my_path',

  webpack: (config) => {
    return config
  },

  env: {
  },

  publicRuntimeConfig: {
    BACKEND_API_URL: process.env.BACKEND_API_URL,
    CONSENT_COOKIE_NAME: 'ConsentCookie'
  },
}

```

I have a gut feeling that this is the reason why [https://localhost:3000/api/auth/me](https://localhost:3000/api/auth/me) cannot be found. Should it instead be [https://localhost:3000/my\_path/api/auth/me](https://localhost:3000/my_path/api/auth/me) ?  
If so, how do I modify this endpoint?

---

<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:** [May 7, 2022, 12:12am UTC](https://community.auth0.com/t/http-localhost-3000-api-auth-me-returns-404-in-console/82831/7 "2022-05-07T00:12:57Z")

</div>

Hey @wisenickel5 thanks for the detailed information, just getting around to this!

> [@wisenickel5](#):
>
> I have a gut feeling that this is the reason why [https://localhost:3000/api/auth/me](https://localhost:3000/api/auth/me) cannot be found. Should it instead be [https://localhost:3000/my\_path/api/auth/me](https://localhost:3000/my_path/api/auth/me) ?  
> If so, how do I modify this endpoint?

I am leaning this way as well - Have you tested the sample app without setting a `basePath`? Regardless, looking [here](https://github.com/auth0/nextjs-auth0/blob/e70112ebff74993b7fd1c8194b8a66c418ac84ab/src/frontend/use-user.tsx#L184) and [here](https://github.com/auth0/nextjs-auth0/blob/625cf2e6d15ec65909d67459075c4057c08f8b19/EXAMPLES.md#use-custom-auth-urls), what happens if you set `NEXT_PUBLIC_AUTH0_PROFILE` in your `.env.local` file to `NEXT_PUBLIC_AUTH0_PROFILE="/my_path/api/auth/me"`

Like I said I’m not super familiar with Next.js nor this SDK, but I think you’re on the right path!

Let us know 🤞

---

<div class="post-metadata">

**Author:** ![wisenickel5](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/wisenickel5/32/37076_2.png) [@wisenickel5](https://community.auth0.com/u/wisenickel5)\
**Post date:** [May 9, 2022, 9:55pm UTC](https://community.auth0.com/t/http-localhost-3000-api-auth-me-returns-404-in-console/82831/8 "2022-05-09T21:55:56Z")

</div>

@ty.frith I am feeling intense bittersweet emotions after finding an insultingly simple solution to this issue.

Found in the [readme.md](https://github.com/auth0/nextjs-auth0#base-path-and-internationalized-routing) of the NextJS-Auth0 repository…  
This small snippet of code fixed all of my issues after hours of searching for a solution -

```plaintext
// _app.js
function App({ Component, pageProps }) {
  return (
    <UserProvider loginUrl="/foo/api/auth/login" profileUrl="/foo/api/auth/me">
      <Component {...pageProps} />
    </UserProvider>
  );
}

```

Now to get back to wiping the tears off my desk…

---

<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:** [May 9, 2022, 11:14pm UTC](https://community.auth0.com/t/http-localhost-3000-api-auth-me-returns-404-in-console/82831/9 "2022-05-09T23:14:56Z")

</div>

Hey @wisenickel5 !

> [@wisenickel5](#):
>
> Now to get back to wiping the tears off my desk…

I’m right there with you 😆 That’s entirely new to me… I’m super happy to know that did the trick for you - Thanks for your perseverance and for sharing with the community!

---

<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:** [May 24, 2022, 11:15pm UTC](https://community.auth0.com/t/http-localhost-3000-api-auth-me-returns-404-in-console/82831/10 "2022-05-24T23:15:36Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
