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

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,, and my logout URLs are set to: http://localhost:3000,

this is my project structure

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”

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:

Here’s the code referenced in the readme:

1 Like

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.

1 Like

eventually, the link helps me

1 Like

Thanks for sharing with the community! :rocket:

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