-
Notifications
You must be signed in to change notification settings - Fork 438
Closed
Labels
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
I recently updated from nextjs v15.5.2 to 16.0.6, and @auth0/nextjs-auth0 4.9.0 to v4.13.1.
After the updates, the /auth/login (and all other auth0 SDK mounted routes) return 404 not found; appear to not be mounted any longer.
I migrated from middleware.ts -> proxy.ts and used the Auth0Client.middleware function, passing it the raw Request object.
// proxy.ts
import { authClient } from '@/clients/auth'
export async function proxy(request: Request) {
return await authClient.middleware(request)
}
export const config = {
matcher: ['/admin/:path*'],
}I updated my login links to use an <a> element instead of the nextjs Link element.
I even added a /auth/login/route.ts file and call the Auth0Client.startInteractiveLogin on a GET handler. This did start the login flow, but then the /auth/callback handler could not be found; same with /auth/logout, etc.
Reproduction
- Create a new nextjs app with latest:
pnpm create next-app@latest
pnpm create next-app@latest
✔ What is your project named? … my-app
✔ Would you like to use the recommended Next.js defaults? › No, customize settings
✔ Would you like to use TypeScript? … No / Yes
✔ Which linter would you like to use? › ESLint
✔ Would you like to use React Compiler? … No / Yes
✔ Would you like to use Tailwind CSS? … No / Yes
✔ Would you like your code inside a `src/` directory? … No / Yes
✔ Would you like to use App Router? (recommended) … No / Yes
? Would you like to customize the import alias (`@/*` by default)? › No / Yes- Installed latest nextjs: v16.0.6
- Installed
@auth0/nextjs-auth0: v4.13.1 - Created a
.env.local, copied in my key/secret
# .env.local
APP_BASE_URL="http://localhost:3000"
AUTH0_CLIENT_ID={{client_id}}
AUTH0_CLIENT_SECRET={{secret}}
AUTH0_DOMAIN={{domain}}
AUTH0_SECRET={{secret}}
- Created an auth0 client instance
// clients/auth.ts
import { Auth0Client } from '@auth0/nextjs-auth0/server'
export const authClient = new Auth0Client({
signInReturnToPath: '/admin',
})- Created a
proxy.ts
// proxy.ts
import { authClient } from '@/clients/auth'
export async function proxy(request: Request) {
return await authClient.middleware(request)
}
export const config = {
matcher: ['/admin/:path*'],
}- Updated my check sign in link to be an
<a>element
// /app/admin/layout.tsx
import { authClient } from '@/clients/auth'
export const dynamic = 'force-dynamic'
export default async function AdminLandingPageLayout({ children }: Readonly<{ children: React.ReactNode }>) {
const session = await authClient.getSession()
if (session == null) {
// user is not authenticated
return (
<div className="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
<div className="sm:mx-auto sm:w-full sm:max-w-sm">
<h2 className="mt-10 text-center text-2xl/9 font-bold tracking-tight text-gray-900">
Sign in to your account
</h2>
</div>
<div className="mt-10 sm:mx-auto sm:w-full sm:max-w-sm">
<a
href="/auth/login"
className="flex w-full justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm/6 font-semibold text-white shadow-xs hover:bg-indigo-500 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
>
Sign in
</a>
</div>
</div>
)
}
return <div>{children}</div>
}- Run the app
pnpm run dev - Open the browser: http://localhost:3000/admin
- Click the sign in link
- App shows the 404 Not Found
- Logs show 404 not found
Additional context
No response
nextjs-auth0 version
4.13.1
Next.js version
16.0.6
Node.js version
22.14.0