[PR #5610] [CLOSED] refactor(oidc-provider): Remove dependency on request object #23015

Closed
opened 2026-04-15 21:25:28 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5610
Author: @momoneko
Created: 10/27/2025
Status: Closed

Base: mainHead: refactor/oidc-no-request-dependency


📝 Commits (2)

  • 7d7f0d1 chore(refactor): Remove dependency on request object
  • a366bf3 Update packages/better-auth/src/plugins/oidc-provider/authorize.ts

📊 Changes

2 files changed (+6 additions, -18 deletions)

View changed files

📝 packages/better-auth/src/plugins/oidc-provider/authorize.ts (+3 -9)
📝 packages/better-auth/src/plugins/oidc-provider/index.ts (+3 -9)

📄 Description

With the current setup, in order to call the oidc provider server side, I need to build the request object and pass it directly, which is inconsistent with the main api calls, such as sign-in or get-session.

E.g.

    /* req is the request object passed from Nest */
    const request = {
      headers: fromNodeHeaders(req.headers),
      url: req.url,
    } as Request;
    const response = await this.auth.api.oAuth2authorize({
      request: request,
      asResponse: true,
    });

This PR removes the requirement to pass in requests and gets the data directly from ctx, allowing code such as

    const response = await this.auth.api.oAuth2authorize({
       headers: fromNodeHeaders(req.headers),
       query: req.query,       
       asResponse: true,
    });

Summary by cubic

Removes the OIDC provider’s dependency on the Request object by reading headers and query from ctx, making server-side calls consistent with sign-in and get-session.

  • Refactors

    • Read authorization, sec-fetch-mode, and x-forwarded-for from ctx.headers.
    • Build login redirects from URLSearchParams(ctx.query) instead of parsing ctx.request.url.
    • Remove UNAUTHORIZED error when ctx.request is missing.
  • Migration

    • Stop passing a Request object to oAuth2authorize. Pass headers and query instead.

Written for commit a366bf3af5. 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/5610 **Author:** [@momoneko](https://github.com/momoneko) **Created:** 10/27/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `refactor/oidc-no-request-dependency` --- ### 📝 Commits (2) - [`7d7f0d1`](https://github.com/better-auth/better-auth/commit/7d7f0d1a7ad51a89e61d2691f819a46f39e6bc1f) chore(refactor): Remove dependency on request object - [`a366bf3`](https://github.com/better-auth/better-auth/commit/a366bf3af5568bf0ae58d9c5571be62634e126fc) Update packages/better-auth/src/plugins/oidc-provider/authorize.ts ### 📊 Changes **2 files changed** (+6 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/oidc-provider/authorize.ts` (+3 -9) 📝 `packages/better-auth/src/plugins/oidc-provider/index.ts` (+3 -9) </details> ### 📄 Description With the current setup, in order to call the oidc provider server side, I need to build the request object and pass it directly, which is inconsistent with the main api calls, such as sign-in or get-session. E.g. ```typescript /* req is the request object passed from Nest */ const request = { headers: fromNodeHeaders(req.headers), url: req.url, } as Request; const response = await this.auth.api.oAuth2authorize({ request: request, asResponse: true, }); ``` This PR removes the requirement to pass in requests and gets the data directly from `ctx`, allowing code such as ```typescript const response = await this.auth.api.oAuth2authorize({ headers: fromNodeHeaders(req.headers), query: req.query, asResponse: true, }); ``` <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Removes the OIDC provider’s dependency on the Request object by reading headers and query from ctx, making server-side calls consistent with sign-in and get-session. - **Refactors** - Read authorization, sec-fetch-mode, and x-forwarded-for from ctx.headers. - Build login redirects from URLSearchParams(ctx.query) instead of parsing ctx.request.url. - Remove UNAUTHORIZED error when ctx.request is missing. - **Migration** - Stop passing a Request object to oAuth2authorize. Pass headers and query instead. <sup>Written for commit a366bf3af5568bf0ae58d9c5571be62634e126fc. 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 21:25:28 -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#23015