Custom error handler for auth routes. Return a NextResponse to send a custom error; otherwise the default response is used.
Object with status (HTTP code) and message (error text).
status
message
NextResponse to override the default error, or undefined to use the default.
const onError: ErrorHandler = ({ status, message }) => { if (status === 400) return NextResponse.json({ error: message }, { status: 400 }); return undefined; // Use default handling}; Copy
const onError: ErrorHandler = ({ status, message }) => { if (status === 400) return NextResponse.json({ error: message }, { status: 400 }); return undefined; // Use default handling};
Custom error handler for auth routes. Return a NextResponse to send a custom error; otherwise the default response is used.