Open
Description
Checklist
- The issue can be reproduced in the nextjs-auth0 sample app (or N/A).
- I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
WE have a basic auth middleware in our application to protect staging environments. Implementing a component using the useUser
-hook loses the the basic-auth-credentials (also having all failing 401 errors for every /auth/profile
request in the console is annoying as hell).
Reproduction
- Clone the example repo: https://github.com/larsEichler/auth0-nextjs-middleware-basic-auth-issue
- Set up an Auth0 Application
- Clone .env.dist -> .env
- Provide Auth0 Env-Credentials
- Start app and log in with basic auth:
user:pass
- Navigate through the menu
- Basic auth will reappear
Additional context
This problem seems not to be directly tied to auth0 but SWR. When throwing an error from the SWR fetcher, Basic Auth headers are being lost.
nextjs-auth0 version
4.0.1
Next.js version
15.1.7
Node.js version
22.14.0