# Nextjs + auth0 work at localhost, but return 404 while depoly to vercel

**URL:** <https://community.auth0.com/t/nextjs-auth0-work-at-localhost-but-return-404-while-depoly-to-vercel/112999>\
**Category:** Get Help\
**Tags:** new-universal-login-experience, login-experience\
**Created:** [August 7, 2023, 3:54am UTC](https://community.auth0.com/t/nextjs-auth0-work-at-localhost-but-return-404-while-depoly-to-vercel/112999 "2023-08-07T03:54:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicat1020](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/musicat1020/32/49653_2.png) [@musicat1020](https://community.auth0.com/u/musicat1020)\
**Post date:** [August 7, 2023, 3:54am UTC](https://community.auth0.com/t/nextjs-auth0-work-at-localhost-but-return-404-while-depoly-to-vercel/112999/1 "2023-08-07T03:54:45Z")

</div>

I’ve tried many methods online for several days, but none of them were successful. I’d like to ask how to configure it properly so that Auth0 can work correctly on Vercel.  
I’m using “next”: “^13.0.0” and “@auth0/nextjs-auth0”: “^2.0.0”.  
In the Auth0 settings, my callback URLs are set to: [http://localhost:3000/api/auth/callback](http://localhost:3000/api/auth/callback), https://_.vercel.app/api/auth/callback, and my logout URLs are set to: [http://localhost:3000](http://localhost:3000), https://_.vercel.app.

---

<div class="post-metadata">

**Author:** ![musicat1020](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/musicat1020/32/49653_2.png) [@musicat1020](https://community.auth0.com/u/musicat1020)\
**Post date:** [August 7, 2023, 3:58am UTC](https://community.auth0.com/t/nextjs-auth0-work-at-localhost-but-return-404-while-depoly-to-vercel/112999/2 "2023-08-07T03:58:10Z")

</div>

this is my project structure

 ![image](https://global.discourse-cdn.com/auth0/original/3X/1/1/1186041f9a1911c9464a116ae4b04869bdc2ea4a.png)

---

<div class="post-metadata">

**Author:** ![onlinepenguin](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@onlinepenguin](https://community.auth0.com/u/onlinepenguin)\
**Post date:** [August 16, 2023, 5:18pm UTC](https://community.auth0.com/t/nextjs-auth0-work-at-localhost-but-return-404-while-depoly-to-vercel/112999/3 "2023-08-16T17:18:41Z")

</div>

Having same issue with “next”: “^13.4.3” and “@auth0/nextjs-auth0”: “^3.1.0”

Getting a 404 error: “Failed to load resource: the server responded with a status of 404 () /api/auth/me”

---

<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:** [August 17, 2023, 12:17am UTC](https://community.auth0.com/t/nextjs-auth0-work-at-localhost-but-return-404-while-depoly-to-vercel/112999/4 "2023-08-17T00:17:51Z")

</div>

Hey there @onlinepenguin welcome to the community!

I’m not entirely sure this will resolve your particular issue, but it sounds similar to this stackoverflow post:

> <https://stackoverflow.com/questions/72144091/auth0-endpoint-api-auth-me-returns-a-404-error-in-next-js-app/72178580#72178580>

Here’s the code referenced in the readme:

> **[GitHub - auth0/nextjs-auth0: Next.js SDK for signing in with Auth0](https://github.com/auth0/nextjs-auth0#base-path-and-internationalized-routing)**
>
> Next.js SDK for signing in with Auth0. Contribute to auth0/nextjs-auth0 development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![onlinepenguin](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@onlinepenguin](https://community.auth0.com/u/onlinepenguin)\
**Post date:** [August 17, 2023, 2:16pm UTC](https://community.auth0.com/t/nextjs-auth0-work-at-localhost-but-return-404-while-depoly-to-vercel/112999/6 "2023-08-17T14:16:35Z")

</div>

Thank you tyf! I luckily found the solution to my particular issue - sharing here in case others encounter it.

I used the Next-Flask-Starter template, which routes calls to the Flask backend via a root-level api/ directory. Vercel didn’t like that there was this root-level api/ directory and then also the app/api/auth/… directory for auth0. As soon as I changed the Flask api/ route to something else, everything worked swimmingly.

---

<div class="post-metadata">

**Author:** ![musicat1020](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/musicat1020/32/49653_2.png) [@musicat1020](https://community.auth0.com/u/musicat1020)\
**Post date:** [August 17, 2023, 3:30pm UTC](https://community.auth0.com/t/nextjs-auth0-work-at-localhost-but-return-404-while-depoly-to-vercel/112999/7 "2023-08-17T15:30:59Z")

</div>

eventually, the link helps me

> **[Next.js/JavaScript App Router Code Sample: Basic Authentication](https://developer.auth0.com/resources/code-samples/web-app/nextjs/basic-authentication/typescript-pages-router)**
>
> Code sample of a simple Next.js web application built with JavaScript that implements authentication using Auth0 and Next.js App Router.

---

<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:** [August 17, 2023, 10:28pm UTC](https://community.auth0.com/t/nextjs-auth0-work-at-localhost-but-return-404-while-depoly-to-vercel/112999/8 "2023-08-17T22:28:29Z")

</div>

Thanks for sharing with the community! 🚀

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [August 31, 2023, 10:29pm UTC](https://community.auth0.com/t/nextjs-auth0-work-at-localhost-but-return-404-while-depoly-to-vercel/112999/9 "2023-08-31T22:29:09Z")

</div>

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