[PR #2849] [MERGED] oidcProvider authorize post-auth flow fix #12768

Closed
opened 2026-04-13 08:34:58 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/2849
Author: @BadPirate
Created: 5/31/2025
Status: Merged
Merged: 5/31/2025
Merged by: @Bekacru

Base: mainHead: fix/2461-authorize-from-fetch


📝 Commits (2)

  • 413ae26 oidcProvider authorize post-auth flow fix
  • f17d9aa cleanup and lint

📊 Changes

1 file changed (+27 additions, -14 deletions)

View changed files

📝 packages/better-auth/src/plugins/oidc-provider/authorize.ts (+27 -14)

📄 Description

Issue:

Recommended way to handle login for OIDC Provider flow is to call authClient.signIn -- However, many of the callbacks in authorize.ts endpoint directly throw their redirects, in many of these cases this is not desired as it will redirect the fetch request when the intent is to redirect the browser instead.

Fix:

If the call is coming from a cors (non-browser navigate) fetch call when doing the consent page redirect or the final authorization callback redirect, redirect using a hint in json payload to authClient rather than attempting to redirect the CORS call.

This resolves issues both with CORS (that people were seeing) as well as well as removing the need for the work around hack provided in #2461

Tested: Locally, using updated code, oidcProvider and a genericOauth client. Verified happy paths for login with / without scope, there are some other issues with consent flow in general, but I'll address those in a different PR.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/2849 **Author:** [@BadPirate](https://github.com/BadPirate) **Created:** 5/31/2025 **Status:** ✅ Merged **Merged:** 5/31/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `fix/2461-authorize-from-fetch` --- ### 📝 Commits (2) - [`413ae26`](https://github.com/better-auth/better-auth/commit/413ae26dbee8e36ec573ee9d006e024e54765c08) oidcProvider authorize post-auth flow fix - [`f17d9aa`](https://github.com/better-auth/better-auth/commit/f17d9aa09fa5215581c9c9c28f27aa81e412e0c9) cleanup and lint ### 📊 Changes **1 file changed** (+27 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/oidc-provider/authorize.ts` (+27 -14) </details> ### 📄 Description Issue: Recommended way to handle login for OIDC Provider flow is to call authClient.signIn -- However, many of the callbacks in authorize.ts endpoint directly throw their redirects, in many of these cases this is not desired as it will redirect the fetch request when the intent is to redirect the browser instead. Fix: If the call is coming from a cors (non-browser navigate) fetch call when doing the consent page redirect or the final authorization callback redirect, redirect using a hint in json payload to authClient rather than attempting to redirect the CORS call. This resolves issues both with CORS (that people were seeing) as well as well as removing the need for the work around hack provided in #2461 Tested: Locally, using updated code, oidcProvider and a genericOauth client. Verified happy paths for login with / without scope, there are some other issues with consent flow in general, but I'll address those in a different PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 08:34:58 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#12768