OAuth errors redirect to the internal page #176

Closed
opened 2026-03-13 07:36:21 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @svaraborut on GitHub (Nov 4, 2024).

Describe the bug
When OAuth for integrated providers fails, the application redirects to the internal error page /api/auth/error?error despite providing callbackURL.

Expected behavior
If callbackURL is provided redirect to the callback page.

Additional context
Despite not being explicitly mentioned it is expected that the authentication via integrated providers would have a consistent behavior with Generic OAuth.

Originally created by @svaraborut on GitHub (Nov 4, 2024). **Describe the bug** When OAuth for integrated providers fails, the application redirects to the internal error page `/api/auth/error?error` despite providing `callbackURL`. **Expected behavior** If `callbackURL` is provided redirect to the callback page. **Additional context** Despite not being explicitly mentioned it is expected that the authentication via integrated providers would have a consistent behavior with [Generic OAuth](https://www.better-auth.com/docs/plugins/generic-oauth#error-handling).
Author
Owner

@Bekacru commented on GitHub (Nov 4, 2024):

The reason we're not using the callback URL for error is because it's primarily intended for a success URL where auth is required (e.g., /dashboard). But, I'm open to the ide to add errorCallbackURL or something similar, which would default to the currentURL if not provided. If neither is specified, it would fall back to /api/auth/error.

@Bekacru commented on GitHub (Nov 4, 2024): The reason we're not using the callback URL for error is because it's primarily intended for a success URL where auth is required (e.g., `/dashboard`). But, I'm open to the ide to add `errorCallbackURL` or something similar, which would default to the `currentURL` if not provided. If neither is specified, it would fall back to `/api/auth/error`.
Author
Owner

@svaraborut commented on GitHub (Nov 4, 2024):

Yes, this would be the ideal behavior, as the default error page is quite drastic and not customizable, breaking the app flow even when the user does something innocent like "Cancel" during the OAuth flow.

I originally reported this issue as in v0.6.2 some errors where redirected to the fallback page but some (like "Cancel") were redirected to the callbackURL. Now in v0.7.2.beta-5 I see all of them go straight to the fallback.

@svaraborut commented on GitHub (Nov 4, 2024): Yes, this would be the ideal behavior, as the default error page is quite drastic and not customizable, breaking the app flow even when the user does something innocent like "Cancel" during the OAuth flow. I originally reported this issue as in `v0.6.2` some errors where redirected to the fallback page but some (like "Cancel") were redirected to the `callbackURL`. Now in `v0.7.2.beta-5` I see all of them go straight to the fallback.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#176