@auth0/nextjs-auth0 4.0.0-beta.8 next15.0.3 not working on vercel cloud

I’m experiencing a similar issue to the one discussed in this thread: Trying out v4 beta, receiving generic error

The key difference is that I’ve managed to get it working locally, but when I attempt to access “/auth/login” on either Vercel or my app domain, I receive a generic error message stating “An error occurred while trying to initiate the login request.”

My application is configured as a “Regular Web Application” with the following settings:

Allowed Callback URLs:

https://my.app/auth/callback,
https://my-app.vercel.app/auth/callback,
http://localhost:3000/auth/callback

Allowed Logout URLs:

https://my.app,
https://my-app.vercel.app/,
http://localhost:3000/

My environment variables are set as follows:

.env.local

AUTH0_DOMAIN='auth.my.app'
AUTH0_CLIENT_ID='...'
AUTH0_CLIENT_SECRET='...'
AUTH0_SECRET='...'
APP_BASE_URL='http://localhost:3000'

.env.production

AUTH0_DOMAIN='auth.my.app'
AUTH0_CLIENT_ID='...'
AUTH0_CLIENT_SECRET='...'
AUTH0_SECRET='...'
APP_BASE_URL='https://my.app'

As I mentioned earlier, this setup works seamlessly on my local machine, but throws an error when deployed to Vercel. The Vercel logs reveal the following error:

Hi: "response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)
    at (node_modules/.pnpm/oauth4webapi@3.1.3/node_modules/oauth4webapi/build/index.js:92:0)
    at (node_modules/.pnpm/oauth4webapi@3.1.3/node_modules/oauth4webapi/build/index.js:221:0)
    at (node_modules/.pnpm/@auth0+nextjs-auth0@4.0.0-beta.8_next@15.0.3_react-dom@18.3.1_react@18.3.1__react@18.3.1_sass_nalkpas7ifge363zka4f67ub7m/node_modules/@auth0/nextjs-auth0/dist/server/auth-client.js:369:36)
    at (node_modules/.pnpm/@auth0+nextjs-auth0@4.0.0-beta.8_next@15.0.3_react-dom@18.3.1_react@18.3.1__react@18.3.1_sass_nalkpas7ifge363zka4f67ub7m/node_modules/@auth0/nextjs-auth0/dist/server/auth-client.js:365:0)
    at (node_modules/.pnpm/@auth0+nextjs-auth0@4.0.0-beta.8_next@15.0.3_react-dom@18.3.1_react@18.3.1__react@18.3.1_sass_nalkpas7ifge363zka4f67ub7m/node_modules/@auth0/nextjs-auth0/dist/server/auth-client.js:92:0)
    at (src/middleware.ts:6:9)
    at (node_modules/.pnpm/next@15.0.3_react-dom@18.3.1_react@18.3.1__react@18.3.1_sass@1.81.0/node_modules/next/dist/esm/server/web/adapter.js:212:0)
    at (node_modules/.pnpm/next@15.0.3_react-dom@18.3.1_react@18.3.1__react@18.3.1_sass@1.81.0/node_modules/next/dist/esm/server/web/adapter.js:163:0) 

and, as @bryso mentioned, it would be really nice to have informative errors, or at least log traces, where we can see which url is requested and what response is receved

Hi @droganov,

Welcome to the Auth0 Community!

What is the value of APP_BASE_URL in the Vercel Environment Variables? Is it set to http://localhost:3000? If so, this is likely the issue. The APP_BASE_URL in Vercel needs to be your Vercel domain. For example, YOUR_VERCEL_DOMAIN.vercel.app.

Here is a guide on deploying Next.js apps with Auth0 to Vercel: How to Deploy a Next.js App Secured By Auth0 to Vercel

I would also recommend submitting feedback about improvements to error messages. You can follow this article regarding feedback: How to Submit Product Feedback or Feature Requests

Best,

Mary Beth

1 Like

Hi @marybeth.hunter
I use:

2023 article is not up-to-date for @auth0/nextjs-auth0 4.0.0-beta.8 and next15.0.3. Looks like I have to create a ticket

Solved here:

1 Like

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