[PR #8628] fix: make custom redirectURI work in oauth flow #25004

Open
opened 2026-04-15 22:41:14 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8628
Author: @ph1p
Created: 3/16/2026
Status: 🔄 Open

Base: mainHead: bugfix/oauth-redirect-uri


📝 Commits (1)

  • 3991b86 fix: make custom redirectURI work in oauth flow

📊 Changes

3 files changed (+51 additions, -4 deletions)

View changed files

📝 packages/better-auth/src/plugins/generic-oauth/generic-oauth.test.ts (+40 -0)
📝 packages/better-auth/src/plugins/generic-oauth/index.ts (+3 -1)
📝 packages/better-auth/src/plugins/generic-oauth/routes.ts (+8 -3)

📄 Description

I know that #8033 has already been closed, but the bug still persists.
These changes fix the issue. It is now possible to pass the redirectURI.


Summary by cubic

Fixes the generic OAuth flow to honor a custom redirectURI from the provider config across the sign-in and callback steps. Adds a test that verifies the custom value is used.

  • Bug Fixes
    • Use provider redirectURI when building the auth URL, in signInWithOAuth2, and during callback token exchange; fallback to ${baseURL}/oauth2/callback/:providerId when not provided.

Written for commit 3991b86456. Summary will update on new commits.


🔄 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/8628 **Author:** [@ph1p](https://github.com/ph1p) **Created:** 3/16/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `bugfix/oauth-redirect-uri` --- ### 📝 Commits (1) - [`3991b86`](https://github.com/better-auth/better-auth/commit/3991b86456567262fa83c9150302fce5e42c0ebe) fix: make custom redirectURI work in oauth flow ### 📊 Changes **3 files changed** (+51 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/generic-oauth/generic-oauth.test.ts` (+40 -0) 📝 `packages/better-auth/src/plugins/generic-oauth/index.ts` (+3 -1) 📝 `packages/better-auth/src/plugins/generic-oauth/routes.ts` (+8 -3) </details> ### 📄 Description I know that #8033 has already been closed, but the bug still persists. These changes fix the issue. It is now possible to pass the redirectURI. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes the generic OAuth flow to honor a custom `redirectURI` from the provider config across the sign-in and callback steps. Adds a test that verifies the custom value is used. - **Bug Fixes** - Use provider `redirectURI` when building the auth URL, in `signInWithOAuth2`, and during callback token exchange; fallback to `${baseURL}/oauth2/callback/:providerId` when not provided. <sup>Written for commit 3991b86456567262fa83c9150302fce5e42c0ebe. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <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-15 22:41:14 -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#25004