TypeError: “secret” is required

I am following the Add Login to Your Next.js Application instructions, and get stuck at step 4: Add the dynamic Route Handler as I keep getting the following error when testing route.js:

throw new TypeError(error.details[0].message);
              ^
TypeError: "secret" is required

Here is my directory structure:

  • project_root_directory/.env.local
  • project_root_directory/src/pages/api/auth/[auth0]/route.js)

I test it by adding:
console.log("the AUTH0_SECRET env var is set: ", !!process.env.AUTH0_SECRET);

which always returns:
the AUTH0_SECRET env var is set: false

Also, Next.js has two different routers: the App Router and the Pages Router, and we need to get this working with the Pages Router. Is there a tutorial on how to achieve these instructions with the Pages Router.

I would love some insights on what I am doing wrong.

Instructions reference

Thank you!

Hi @startup,

Welcome to the Auth0 Community!

It seems that the error is indicating that you are missing a secret value. Please ensure that the secret value is set and located in the correct place.

Here is an example of configuring the Page Router, which you can reference:
Auth0 Next.js SDK - Page Router setup

Let me know if you have any questions.

Thanks,
Rueben

1 Like

Hi @rueben.tiow ,

Thanks for the article! Long story short, it seems that the issue was actually the version of '@auth0/nextjs-auth0'.

Thanks for your help!
The Startup

1 Like

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