Auth0 works local but not in production nextjs

Auth0 works fine on localhost so I want to deploy it on Azure static website. I changed the AUTH0_BASE_URL to my custom domain and add it to the allowed URL’s in the auth0 application settings.
My app works fine on the hosted domain but when I navigate to mydomain/api/auth/login a notfound error is shown.
I have looked into the out folder. There is no api folder with a auth0 file.
Do I need to deploy it on a web app with the .next folder or do I need something else?