Next.js Callback 404 Not Found Error

Overview

This article explains why a 404 Not Found error may be seen on the /api/auth/callback route when utilizing the nextjs-auth0 library.

Applies To

  • NextJS-Auth0

 

Cause

If the callback looks similar to the following error, with <AUTH0-DOMAIN> being the domain associated with the Auth0 tenant, this error is happening because of the misuse of the Auth0 domain.

https://<AUTH0-DOMAIN>/api/auth/callback

  • The Auth0 domain should only be utilized to complete calls towards one of the Auth0-managed APIs
  • The error occurs because the /api/auth/callback is not an Auth0 API endpoint, but rather a route in the application.

Solution

  1. Verify that the environment variable AUTH0_BASE_URL exists within the .env configuration file for applications built with the NextJS-Auth0 SDK.
  2. Set the AUTH0_BASE_URL variable to the base URL where the Next.js application is hosted.
  3. Confirm the AUTH0_BASE_URL variable contains the application's hosting URL, not the Auth0 tenant domain.
    • Example of an incorrect value (tenant domain): https://<tenant_name>.<region>.auth0.com/
  4. If issues continue, check the configured AUTH0_BASE_URL domain for correct spelling and validity.

Recommended content

No recommended content found...