3

How to login in a next js app with auth0? I followed the quickstart from the auth0 website and I am getting this error on the login page.

<a href="/api/auth/login">Login</a>

This is pages/api/[...auth0].js

import { handleAuth } from '@auth0/nextjs-auth0';

export default handleAuth();

I am getting this error on the login page.

error on login

and I am getting this in my terminal

OPError: expected 200 OK, got: 404 Not Found
    at processResponse (/home/madhav/Documents/Web Development/freelancing/frontend-affilboost/node_modules/openid-client/lib/helpers/process_response.js:48:11)
    at Function.discover (/home/madhav/Documents/Web Development/freelancing/frontend-affilboost/node_modules/openid-client/lib/issuer.js:252:22)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  error: 'expected 200 OK, got: 404 Not Found'
}

I am getting Failed to load resource, the server responded with code 500 in my browsers' console.

What am I doing wrong?

2
  • Having this exact same issue and just searched for way too long to find this SO post. Sorry I'm adding no value, but I'm commenting so I can follow along and to let you know you are not alone. Commented Jul 3, 2021 at 1:22
  • 2
    that's wholesome Commented Jul 3, 2021 at 10:32

3 Answers 3

5

The issue you're likely experiencing here is the following:

  1. In your .env.local file AUTH0_BASE_URL should be set to http://localhost:<port>
  2. In you .env.local file AUTH0_ISSUER_BASE_URL should be set to your Auth0 domain: https://xxx.us.auth0.com
  3. Make sure your callback URL inside of Auth0 is set to http://localhost:<port>/api/auth/callback

Replace <port> with whatever port you're using locally to serve the application.

Sign up to request clarification or add additional context in comments.

1 Comment

This should be marked as answer :)
2

Bumped into the same thing, I know it's unlikely but don't forget to create a folder /auth inside your /api folder. I got the same error until I figured this out.

auth0

Comments

0

Changing .env to .env.local was the fix for me.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.