Skip to content

Add onError callback for customizing error handling in handleAuth#193

Merged
nicknisi merged 4 commits intomainfrom
nicnkisi/callback-route-error-resolver
Jan 29, 2025
Merged

Add onError callback for customizing error handling in handleAuth#193
nicknisi merged 4 commits intomainfrom
nicnkisi/callback-route-error-resolver

Conversation

@nicknisi
Copy link
Member

@nicknisi nicknisi commented Jan 28, 2025

Add an optional onError callback that can be used to customize how errors are handled in withAuth.

import { handleAuth } from '@workos-inc/authkit-nextjs';

export const GET = handleAuth({
  onError: ({ error, request }) => {
    // do something with the error
    return NextResponse.redirect('/somewhere');
  }
});

Fixes #192

@nicknisi nicknisi requested a review from mthadley January 28, 2025 15:17
@nicknisi nicknisi changed the title Add resolveErrorResponse callback for customizing error message in auth callback Add onError callback for customizing error handling in handleAuth Jan 28, 2025
Copy link

@chamini2 chamini2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I don't work in WorkOS, but looks pretty straightforward to me! Thanks for the quick response.

Would appreciate if we can get a new version when this is merged!

@nicknisi nicknisi requested a review from cmatheson January 29, 2025 17:04
@nicknisi nicknisi merged commit a0fb119 into main Jan 29, 2025
4 checks passed
@nicknisi nicknisi deleted the nicnkisi/callback-route-error-resolver branch January 29, 2025 19:05
@nicknisi nicknisi mentioned this pull request Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Allow to add custom onError handler

3 participants