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

**URL:** <https://community.auth0.com/t/auth0-nextjs-auth0-4-0-0-beta-8-next15-0-3-not-working-on-vercel-cloud/156307>\
**Category:** Get Help\
**Tags:** configuration, application\
**Created:** [December 1, 2024, 8:20pm UTC](https://community.auth0.com/t/auth0-nextjs-auth0-4-0-0-beta-8-next15-0-3-not-working-on-vercel-cloud/156307 "2024-12-01T20:20:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![droganov](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/droganov/32/60177_2.png) [@droganov](https://community.auth0.com/u/droganov)\
**Post date:** [December 1, 2024, 8:20pm UTC](https://community.auth0.com/t/auth0-nextjs-auth0-4-0-0-beta-8-next15-0-3-not-working-on-vercel-cloud/156307/1 "2024-12-01T20:20:58Z")

</div>

I’m experiencing a similar issue to the one discussed in this thread: [Trying out v4 beta, receiving generic error](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286)

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:**

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

```

**Allowed Logout URLs:**

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

```

My environment variables are set as follows:

**.env.local**

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

```

**.env.production**

```auto
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:

```auto
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

---

<div class="post-metadata">

**Author:** ![marybeth.hunter](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/marybeth.hunter/32/61955_2.png) [@marybeth.hunter](https://community.auth0.com/u/marybeth.hunter)\
**Post date:** [December 2, 2024, 9:04pm UTC](https://community.auth0.com/t/auth0-nextjs-auth0-4-0-0-beta-8-next15-0-3-not-working-on-vercel-cloud/156307/3 "2024-12-02T21:04:05Z")

</div>

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](https://developer.auth0.com/resources/guides/web-app/nextjs/vercel-deployment)

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](https://community.auth0.com/t/how-to-submit-product-feedback-or-feature-requests/22150)

Best,

Mary Beth

---

<div class="post-metadata">

**Author:** ![droganov](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/droganov/32/60177_2.png) [@droganov](https://community.auth0.com/u/droganov)\
**Post date:** [December 3, 2024, 9:02am UTC](https://community.auth0.com/t/auth0-nextjs-auth0-4-0-0-beta-8-next15-0-3-not-working-on-vercel-cloud/156307/4 "2024-12-03T09:02:30Z")

</div>

Hi @marybeth.hunter  
I use:

> [@droganov](#):
>
> `APP_BASE_URL='https://my.app'`

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

---

<div class="post-metadata">

**Author:** ![droganov](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/droganov/32/60177_2.png) [@droganov](https://community.auth0.com/u/droganov)\
**Post date:** [December 3, 2024, 11:12pm UTC](https://community.auth0.com/t/auth0-nextjs-auth0-4-0-0-beta-8-next15-0-3-not-working-on-vercel-cloud/156307/5 "2024-12-03T23:12:05Z")

</div>

Solved here:

> <https://github.com/auth0/nextjs-auth0/issues/1832#issuecomment-2515680592>
>
> \### Checklist
> 
> \- \[X\] The issue can be reproduced in the \[nextjs-auth0 sample app…\](https://github.com/auth0-samples/auth0-nextjs-samples/tree/main/Sample-01) (or N/A).
> \- \[X\] I have looked into the \[Readme\](https://github.com/auth0/nextjs-auth0#readme), \[Examples\](https://github.com/auth0/nextjs-auth0/blob/main/EXAMPLES.md), and \[FAQ\](https://github.com/auth0/nextjs-auth0/blob/main/FAQ.md) and have not found a suitable solution or answer.
> \- \[X\] I have looked into the \[API documentation\](https://auth0.github.io/nextjs-auth0/) and have not found a suitable solution or answer.
> \- \[X\] I have searched the \[issues\](https://github.com/auth0/nextjs-auth0/issues) and have not found a suitable solution or answer.
> \- \[X\] I have searched the \[Auth0 Community\](https://community.auth0.com) forums and have not found a suitable solution or answer.
> \- \[X\] I agree to the terms within the \[Auth0 Code of Conduct\](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md).
> 
> \### Description
> 
> I’m experiencing a similar issue to the one discussed in this thread: \[Trying out v4 beta, receiving generic error\](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286)
> 
> 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\](https://community.auth0.com/u/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
> 
> \### Reproduction
> 
> src/components/Auth/auth0SDK.ts:
> \`\`\`
> import { Auth0Client } from '@auth0/nextjs-auth0/server'
> 
> export const auth0SDK = new Auth0Client({})
> \`\`\`
> 
> src/middleware.ts
> \`\`\`
> import type { NextRequest, NextResponse } from 'next/server'
> 
> import { auth0SDK } from './components/Auth/auth0SDK'
> 
> export async function middleware(request: NextRequest): Promise\<NextResponse\> {
> return await auth0SDK.middleware(request)
> }
> 
> export const config = {
> matcher: \[
> /\*
> \* Match all request paths except for the ones starting with:
> \* - \_next/static (static files)
> \* - \_next/image (image optimization files)
> \* - favicon.ico, sitemap.xml, robots.txt (metadata files)
> \*/
> '/((?!\_next/static|\_next/image|favicon.ico|sitemap.xml|robots.txt).\*)',
> \],
> }
> \`\`\`
> 
> .env.production
> \`\`\`
> AUTH0\_DOMAIN='auth.my.app'
> AUTH0\_CLIENT\_ID='...screened'
> AUTH0\_CLIENT\_SECRET='...screened'
> AUTH0\_SECRET='...screened'
> APP\_BASE\_URL='https://my.app'
> \`\`\`
> 
> src/components/Auth/useAuth.ts
> \`\`\`
> import { useUser } from '@auth0/nextjs-auth0'
> 
> import { useIsMounted } from '../../ui/icons/hooks/useIsMounted'
> 
> export type UserContext = ReturnType\<typeof useUser\>
> 
> export const useAuth = (): null | UserContext =\> {
> const userContext = useUser()
> const isMounted = useIsMounted()
> return isMounted ? userContext : null
> }
> \`\`\`
> 
> src/components/Auth/DashboardLink.tsx
> \`\`\`
> /\* eslint-disable @next/next/no-html-link-for-pages \*/
> 'use client'
> 
> import type { FunctionComponent } from 'react'
> 
> import { useAuth } from './useAuth'
> 
> const className = 'btn bg-paper-reverse btn-sm rounded-full'
> 
> export const DashboardLink: FunctionComponent = () =\> {
> const auth = useAuth()
> 
> if (auth?.user) {
> return (
> \<div\>
> \<a className={className} href="/dashboard"\>
> {/\* \<a className={className} href="/auth/logout"\> \*/}
> Dashboard
> \</a\>
> \</div\>
> )
> }
> 
> return (
> \<a className={className} href="/auth/login"\>
> Sign In
> \</a\>
> )
> }
> \`\`\`
> 
> Visiting \`/auth/login\` results in \`An error occured while trying to initiate the login request.\`
> 
> \### Additional context
> 
> \_No response\_
> 
> \### nextjs-auth0 version
> 
> @auth0/nextjs-auth0 4.0.0-beta.8
> 
> \### Next.js version
> 
> next15.0.3
> 
> \### Node.js version
> 
> 20.10.0

---

<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:** [December 17, 2024, 11:13pm UTC](https://community.auth0.com/t/auth0-nextjs-auth0-4-0-0-beta-8-next15-0-3-not-working-on-vercel-cloud/156307/6 "2024-12-17T23:13:05Z")

</div>

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