You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(nextjs-auth0 sample app is v3, so reproduction not possible)
Upgrading from v3, using an existing App, I see a "An error occured while trying to exchange the authorization code." error in the /auth/callback route.
When I use the regular *.eu.auth0.com from my AUTH0_DOMAIN config it works as expected.
When using my custom domain instead, I see the above error.
full stack trace;
'OperationProcessingError: "response" is not a conform Token Endpoint response (unexpected HTTP status code)\n at OPE (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected]/node_modules/oauth4webapi/build/index.js:183:12)\n at checkOAuthBodyError (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected]/node_modules/oauth4webapi/build/index.js:951:15)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async processGenericAccessTokenResponse (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected]/node_modules/oauth4webapi/build/index.js:1234:5)\n at async processAuthorizationCodeOpenIDResponse (webpack-internal:///(middleware)/./node_modules/.pnpm/[email protected]/node_modules/oauth4webapi/build/index.js:1445:20)'
thrown in /nextjs-auth0/dist/server/auth-client.js, line 262
This custom domain is not new, it is in use for several other apps, and works as expected with the v3 SDK
Reproduction
simple src/lib/auth0.ts
import { Auth0Client } from "@auth0/nextjs-auth0/server";
import { NextRequest, NextResponse } from "next/server";
/**
* Create a bare-minimum Auth0 client using environment variables
*/
export const auth0 = new Auth0Client();
simple root src/app/page.tsx
import { auth0 } from "@/lib/auth0";
import Link from "next/link";
export default async function Home() {
const session = await auth0.getSession();
... do something with session, login button etc
}
barebones middleware
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { auth0 } from "./lib/auth0";
export async function middleware(request: NextRequest) {
try {
// Let Auth0 handle authentication routes
return await auth0.middleware(request);
} catch (error) {
console.error("Auth0 middleware error:", error);
}
}
export const config = {
matcher: [
/*
* Match all request paths except for the ones starting with:
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico, sitemap.xml, robots.txt (metadata files)
*/
"/((?!_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)"
]
};
my .env.local looks like;
AUTH0_SECRET='...'
APP_BASE_URL='http://localhost:9000'
AUTH0_DOMAIN='my-domain.auth0.com' OR 'my-custom-domain.com'
AUTH0_CLIENT_ID='...'
AUTH0_CLIENT_SECRET='...'
API_BASE_URL=http://localhost:3000
AUTH0_AUDIENCE=https://other-server
Additional context
My auth0 logs display "Success Login" for logins for both the custom domain, an the .auth0 domain configs, and no other errors.
nextjs-auth0 version
4.0.3
Next.js version
14.1.4
Node.js version
21.5.0
The text was updated successfully, but these errors were encountered:
Checklist
Description
(nextjs-auth0 sample app is v3, so reproduction not possible)
Upgrading from v3, using an existing App, I see a "An error occured while trying to exchange the authorization code." error in the
/auth/callback
route.When I use the regular
*.eu.auth0.com
from my AUTH0_DOMAIN config it works as expected.When using my custom domain instead, I see the above error.
full stack trace;
thrown in /nextjs-auth0/dist/server/auth-client.js, line 262
This custom domain is not new, it is in use for several other apps, and works as expected with the v3 SDK
Reproduction
my .env.local looks like;
Additional context
My auth0 logs display "Success Login" for logins for both the custom domain, an the .auth0 domain configs, and no other errors.
nextjs-auth0 version
4.0.3
Next.js version
14.1.4
Node.js version
21.5.0
The text was updated successfully, but these errors were encountered: