# Trying out v4 beta, receiving generic error

**URL:** <https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286>\
**Category:** Get Help\
**Tags:** configuration, application\
**Created:** [November 11, 2024, 2:55pm UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286 "2024-11-11T14:55:54Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![bryso](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bryso/32/59788_2.png) [@bryso](https://community.auth0.com/u/bryso)\
**Post date:** [November 11, 2024, 2:55pm UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286/1 "2024-11-11T14:55:54Z")

</div>

```auto
An error occured while trying to initiate the login request.

```

I followed the [instructions here](https://www.npmjs.com/package/@auth0/nextjs-auth0/v/4.0.0-beta.0), but I’m receiving the generic error above and I’m unable to make any headway. Does anyone have more detail about what specifically is wrong?

Side note, I’m also trying to upgrade to NextJs 15 (to resolve the caching introduced in previous versions). I read somewhere that v4 supports Next 15, so that’s why I’m trying it out now.

---

<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:** [November 13, 2024, 11:33pm UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286/3 "2024-11-13T23:33:29Z")

</div>

Hi @bryso,

Can you provide more information? I’m assuming from the error message that this error comes about after a login attempt. Is it when you click the login button? Do you see an error page or console errors apart from what you’ve shared?

As much information you can provide as possible will be helpful. Screenshots/screen recordings are also welcome.

Thanks,

Mary Beth

---

<div class="post-metadata">

**Author:** ![bryso](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bryso/32/59788_2.png) [@bryso](https://community.auth0.com/u/bryso)\
**Post date:** [November 14, 2024, 3:10pm UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286/4 "2024-11-14T15:10:26Z")

</div>

Hey Beth,

Yes, when I click a button that links to /auth/login. I’m guessing something is incorrect with my configuration with the Application URIs, but it was working before so I don’t know why they would suddenly be wrong 🤔.

I’ve tried a number of different ways. First with my app I’ve been working on for the last year and I’m trying to upgrade. When that wouldn’t work, I tried the Sample-01 example that Auth0 provides for configuring Next apps. For this I made the necessary changes to upgrade it to v4. Finally I found another example specific to v4 [here](https://github.com/auth0/nextjs-auth0/tree/v4/examples/with-shadcn) and tried that. All had the same issue. The video below shows what happens:

Link with video:

> **[Proton Drive](https://drive.proton.me/urls/F9S6N60H0R#JGYo6S8ry0dk)**
>
> Securely store, share, and access your important files and photos. Anytime, anywhere.

Thanks for the help 🙏

---

<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:** [November 15, 2024, 6:50pm UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286/5 "2024-11-15T18:50:26Z")

</div>

Hi @bryso,

Unfortunately, I cannot view that link. Can you share it another way? Following the [Next.js Quickstart](https://auth0.com/docs/quickstart/webapp/nextjs/interactive), the Allowed Callback URL needs to end in `/api/auth/callback`. So for localhost, it would be `http://localhost:3000/api/auth/callback`. Could you kindly try changing your Allowed Callback URL?

I look forward to your reply!

Thanks,

Mary Beth

---

<div class="post-metadata">

**Author:** ![o.sevcik91](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/o.sevcik91/32/62268_2.png) [@o.sevcik91](https://community.auth0.com/u/o.sevcik91)\
**Post date:** [November 17, 2024, 11:57am UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286/6 "2024-11-17T11:57:56Z")

</div>

@bryso  
I had issue with .env having https, once changed to without https. The login url started to work.

AUTH0\_DOMAIN=“.eu.auth0.com”

V3 supported https:// in AUTH0\_DOMAIN and it looks like it has been dropped in V4. Find it out by console logging middleware object and seeing double https in issuer

---

<div class="post-metadata">

**Author:** ![o.sevcik91](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/o.sevcik91/32/62268_2.png) [@o.sevcik91](https://community.auth0.com/u/o.sevcik91)\
**Post date:** [November 17, 2024, 11:58am UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286/7 "2024-11-17T11:58:46Z")

</div>

Can’t edit above:

AUTH0\_DOMAIN=“[yourdomain.eu.auth0.com](http://yourdomain.eu.auth0.com)”

---

<div class="post-metadata">

**Author:** ![bryso](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bryso/32/59788_2.png) [@bryso](https://community.auth0.com/u/bryso)\
**Post date:** [November 17, 2024, 4:58pm UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286/8 "2024-11-17T16:58:14Z")

</div>

@marybeth.hunter

Thanks, but changing that doesn’t resolve the “An error occurred while trying to initiate the login request.” error when I click my login button and am taken to my /auth/login page. One thing I’m unclear on, is with v4, do we still use the /api/auth endpoint in our app? I figured that since it wasn’t included in the readMe for v4, we no longer use that so I removed it from my code. Am I off base here?

---

<div class="post-metadata">

**Author:** ![bryso](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bryso/32/59788_2.png) [@bryso](https://community.auth0.com/u/bryso)\
**Post date:** [November 17, 2024, 5:00pm UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286/9 "2024-11-17T17:00:28Z")

</div>

@ [o.sevcik91](https://community.auth0.com/u/o.sevcik91)

Thanks for the reply. I tried your suggestion, but it didn’t resolve the issue. I’m a little unclear what you mean by logging the middleware object. Can you expand on that? Are you speaking of the request that’s sent to the middleware? Or the response that we wait for from `auth0.middleware(request)` ?

---

<div class="post-metadata">

**Author:** ![o.sevcik91](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/o.sevcik91/32/62268_2.png) [@o.sevcik91](https://community.auth0.com/u/o.sevcik91)\
**Post date:** [November 18, 2024, 5:28am UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286/10 "2024-11-18T05:28:46Z")

</div>

@bryso

I also followed steps that are [here](https://www.npmjs.com/package/@auth0/nextjs-auth0/v/4.0.0-beta.3) and logged it like in the code below. Then checked all the values to discover an issue ([https://https](https://https)://yourdomain.eu.auth0.com as value)

Also make sure you are using APP\_BASE\_URL (if I remember correctyl it was renamed from AUTH0\_BASE\_URL)

middleware.ts in root

```auto
import { auth0 } from '@/utils/auth0';
import type { NextRequest } from 'next/server';

export async function middleware(request: NextRequest) {
  console.log('middleware', auth0);
  return await auth0.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).*)',
  ],
};

```

/utils/auth0.ts

```auto
import { Auth0Client } from '@auth0/nextjs-auth0/server';

export const auth0 = new Auth0Client();

```

---

<div class="post-metadata">

**Author:** ![bryso](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bryso/32/59788_2.png) [@bryso](https://community.auth0.com/u/bryso)\
**Post date:** [November 18, 2024, 4:02pm UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286/11 "2024-11-18T16:02:04Z")

</div>

@ [o.sevcik91](https://community.auth0.com/u/o.sevcik91)

Logging out the value in the middleware as you showed didn’t reveal anything to me, this is what I received:

```auto
{
  cookies: ResponseCookies {},
  url: '',
  body: ReadableStream {
  [Symbol(kType)]: 'ReadableStream',
  [Symbol(kState)]: <ref *1> {
  disturbed: false,
  reader: undefined,
  state: 'readable',
  storedError: undefined,
  stream: undefined,
  transfer: {
  writable: undefined,
  port1: undefined,
  port2: undefined,
  promise: undefined
}

```

I’m very confused about v3 vs v4 configuration . What EXACTLY is needed? Which ENV variables and what code? Is the /api/auth directory needed anymore?

---

<div class="post-metadata">

**Author:** ![o.sevcik91](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/o.sevcik91/32/62268_2.png) [@o.sevcik91](https://community.auth0.com/u/o.sevcik91)\
**Post date:** [November 18, 2024, 5:11pm UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286/12 "2024-11-18T17:11:32Z")

</div>

@bryso Are you console logging exactly the same thing as I do? (auth0)  
You can just copy my code I posted earlier

As mine object has values for all and very different format and different keys

Only middleware.ts in root is required which is using auth0 defined in /lib or /utils (defining it so you can also use it in code) together with those env vars AUTH0\_DOMAIN, AUTH0\_CLIENT\_ID, AUTH0\_CLIENT\_SECRET, AUTH0\_SECRET and APP\_BASE\_URL

Make sure you are also running version 15 of Nextjs and version 4 of @auth0/nextjs-auth0. Maybe reinstall node\_modules could help if you have everything set up.

If nothing helps, try it in the empty project.

```auto
middleware Auth0Client {
  transactionStore: TransactionStore {
  secret: <redacted>,
  cookieConfig: {
  httpOnly: true,
  sameSite: 'lax',
  secure: false,
  path: '/',
  maxAge: 3600
}
},
  sessionStore: StatelessSessionStore {
  SESSION_COOKIE_NAME: '__session',
  cookieConfig: { httpOnly: true, sameSite: 'lax', secure: false, path: '/' },
  secret: <redacted>,
  rolling: true,
  absoluteDuration: 2592000,
  inactivityDuration: 604800,
  store: undefined
},
  authClient: AuthClient {
  fetch: [Function],
  jwksCache: {},
  transactionStore: TransactionStore {
  secret: <redacted>,
  cookieConfig: {
  httpOnly: true,
  sameSite: 'lax',
  secure: false,
  path: '/',
  maxAge: 3600
}
},
  sessionStore: StatelessSessionStore {
  SESSION_COOKIE_NAME: '__session',
  cookieConfig: { httpOnly: true, sameSite: 'lax', secure: false, path: '/' },
  secret: <redacted>,
  rolling: true,
  absoluteDuration: 2592000,
  inactivityDuration: 604800,
  store: undefined
},
  issuer: 'https://dev-<redacted>.eu.auth0.com',
  clientMetadata: { client_id: '<redacted>' },
  clientSecret: '<redacted>',
  redirectUri: URL { },
  authorizationParameters: { scope: 'openid profile email offline_access' },
  appBaseUrl: 'http://localhost:3000',
  signInReturnToPath: '/',
  beforeSessionSaved: undefined,
  onCallback: [Function: defaultOnCallback]
}
}

```

---

<div class="post-metadata">

**Author:** ![aaron.housh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/aaron.housh/32/62304_2.png) [@aaron.housh](https://community.auth0.com/u/aaron.housh)\
**Post date:** [November 18, 2024, 7:00pm UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286/13 "2024-11-18T19:00:55Z")

</div>

setting it without https:// also fixed it for me, but now i get the exact same error message when trying to call logout

---

<div class="post-metadata">

**Author:** ![o.sevcik91](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/o.sevcik91/32/62268_2.png) [@o.sevcik91](https://community.auth0.com/u/o.sevcik91)\
**Post date:** [November 19, 2024, 6:25am UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286/15 "2024-11-19T06:25:58Z")

</div>

Awesome! I hope Auth0 team could implement better error message for that edge case.

---

<div class="post-metadata">

**Author:** ![bryso](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bryso/32/59788_2.png) [@bryso](https://community.auth0.com/u/bryso)\
**Post date:** [November 19, 2024, 3:55pm UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286/16 "2024-11-19T15:55:44Z")

</div>

Looks like I was using `4.0.0-beta.0`. Switching it to the latest, deleting node\_modules and package.lock along with reinstalling gave me something like what you have. I see that the issuer is `https://localhost:3999` which seems wrong 🤔. How exactly is the issuer set?

I’m still getting the same error I originally got:

`An error occured while trying to initiate the login request.`

```auto
Auth0Client {
  transactionStore: TransactionStore {
  secret: <redacted>,
  cookieConfig: {
  httpOnly: true,
  sameSite: 'lax',
  secure: false,
  path: '/',
  maxAge: 3600
}
},
  sessionStore: StatelessSessionStore {
  SESSION_COOKIE_NAME: '__session',
  cookieConfig: { httpOnly: true, sameSite: 'lax', secure: false, path: '/' },
  secret: <redacted>
  rolling: true,
  absoluteDuration: 2592000,
  inactivityDuration: 604800,
  store: undefined
},
  authClient: AuthClient {
  fetch: [Function],
  jwksCache: {},
  transactionStore: TransactionStore {
  secret: <redacted>,
  cookieConfig: {
  httpOnly: true,
  sameSite: 'lax',
  secure: false,
  path: '/',
  maxAge: 3600
}
},
  sessionStore: StatelessSessionStore {
  SESSION_COOKIE_NAME: '__session',
  cookieConfig: { httpOnly: true, sameSite: 'lax', secure: false, path: '/' },
  secret: <redacted>,
  rolling: true,
  absoluteDuration: 2592000,
  inactivityDuration: 604800,
  store: undefined
},
  issuer: 'https://localhost:3999',
  clientMetadata: { client_id: <redacted>},
  clientSecret: <redacted>,
  authorizationParameters: { scope: 'openid profile email offline_access' },
  appBaseUrl: 'http://localhost:3999',
  signInReturnToPath: '/',
  beforeSessionSaved: undefined,
  onCallback: [Function: defaultOnCallback]
}
}

```

---

<div class="post-metadata">

**Author:** ![bryso](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bryso/32/59788_2.png) [@bryso](https://community.auth0.com/u/bryso)\
**Post date:** [November 27, 2024, 3:38pm UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286/17 "2024-11-27T15:38:13Z")

</div>

I looked at the auth0 code from the package and the error is being thrown here:

 ![Screenshot 2024-11-27 at 8.27.12 AM](https://global.discourse-cdn.com/auth0/original/3X/b/7/b792e5c247401f3db247678b15cdb7a4e05e8528.png)

 ![Screenshot 2024-11-27 at 8.28.29 AM](https://global.discourse-cdn.com/auth0/original/3X/f/3/f382d5fffa00d6e45299942d8aa1fb461d2110f1.png)

I’m assuming the problem is related to my issuer being set as `issuer: 'https://localhost:3999',` on the `auth0` object as I mentioned in the previous comment. Does anyone know why it would be getting set to https? I double checked my config and I am not setting it that way. Is anybody else able to work with this beta locally?

---

<div class="post-metadata">

**Author:** ![bryso](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bryso/32/59788_2.png) [@bryso](https://community.auth0.com/u/bryso)\
**Post date:** [November 28, 2024, 8:43pm UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286/18 "2024-11-28T20:43:46Z")

</div>

It looks like the issue was that `AUTH0_DOMAIN` was set to localhost instead of the domain Auth0 provides for it’s identity service (the ENV variable that used to be `AUTH0_ISSUER_BASE_URL`). In addition to that, [o.sevcik91](https://community.auth0.com/u/o.sevcik91) was right that it should exclude the protocol.

A Quality of life improvement from the Auth0 team would be to give a more descriptive error message here to help point me to the problem at hand. Instead of:

```auto
An error occurred while trying to initiate the login request.

```

Maybe in `discoverAuthorizationServerMetadata` they could add some logic to interpret the error a little better and in `handleLogin` give a more user friendly error such as `An error occured while trying to initiate the login request. This can potentially be from your AUTH0\_DOMAIN being set incorrectly.

Thanks for help everyone!

---

<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 22, 2024, 11:11am UTC](https://community.auth0.com/t/trying-out-v4-beta-receiving-generic-error/151286/20 "2024-12-22T11:11:58Z")

</div>

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