Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add onError callback for customizing error handling in handleAuth #193

Merged
merged 4 commits into from
Jan 29, 2025

Conversation

nicknisi
Copy link
Contributor

@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!

README.md Outdated Show resolved Hide resolved
@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