nextjs-auth0 icon indicating copy to clipboard operation
nextjs-auth0 copied to clipboard

404 error when following basic setup instructions

Open robliou opened this issue 10 months ago • 3 comments

Checklist

  • [X] The issue can be reproduced in the nextjs-auth0 sample app (or N/A).
  • [X] I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
  • [X] I have looked into the API documentation and have not found a suitable solution or answer.
  • [X] I have searched the issues and have not found a suitable solution or answer.
  • [X] I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • [X] I agree to the terms within the Auth0 Code of Conduct.

Description

Hello, I'm following the basic nextjs-auth0 example to try to add auth0 authentication to my nextjs app.

However, I keep getting 404: not found error when trying to access the login route located at /api/auth/login.

For the record, I am just deploying locally (localhost:3000). I am using the NextJS app router and have setup everything according to the instructions page, including setting up the application in my Auth0 dashboard.

Reproduction

  1. follow instructions at https://github.com/auth0/nextjs-auth0 for registering and configuring the app in auth0 dashboard 1a) add AUTH0_BASE_URL, AUTH0_ISSUER_BASE_URL, AUTH0_CLIENT_ID, AUTH0_CLIENT_SECRET values to .env file.
  2. add route.js file which imports and then exports handleAuth at /app/api/auth/[auth0]/route.js (note that I have a parent src directory above the app directory)
  3. add UserProvider to layout.js via:
import { UserProvider } from '@auth0/nextjs-auth0/client';

export default function App({ children }) {
  return (
    <UserProvider>
      <body>{children}</body>
    </UserProvider>
  );
}
  1. create a button to call the login route in your Header.js or Page.js file via:
<a href="/api/auth/login">Login</a>;
  1. clicking this button should reroute you to http://localhost:3000/api/auth/login, however, at this route, I get a 404 error?

It seems like I'm missing something very simple and basic here, but can't figure out what it is? Thank you in advance,

Additional context

No response

nextjs-auth0 version

3.5.0

Next.js version

14.1.3

Node.js version

20

robliou avatar Apr 15 '24 05:04 robliou