[PR #3155] [MERGED] fix: protocol-specific wildcard trusted origins does not work #21576

Closed
opened 2026-04-15 20:27:47 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3155
Author: @nascode
Created: 6/24/2025
Status: Merged
Merged: 7/5/2025
Merged by: @Bekacru

Base: mainHead: fix/protocol-specific-wildcards


📝 Commits (1)

  • 4d0f01a fix(origin-check): support protocol-specific wildcard trusted origins

📊 Changes

2 files changed (+48 additions, -0 deletions)

View changed files

📝 packages/better-auth/src/api/middlewares/origin-check.test.ts (+38 -0)
📝 packages/better-auth/src/api/middlewares/origin-check.ts (+10 -0)

📄 Description

fix https://github.com/better-auth/better-auth/issues/3154

Summary

The changes fix a bug where protocol-specific wildcard patterns like https://*.example.com do not work. This happen because there is a missing logic, if protocol is defined in wildcard trusted origins, we should consider entire url, not only the host to be matched.

Changes made:

  1. Fixed wildcard matching logic.
  2. Added test coverage - New test case validates both positive and negative scenarios for protocol-specific wildcards.
  3. Applied fix to both middleware functions - Both originCheckMiddleware and originCheck now handle protocol-specific wildcards correctly.

🔄 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/3155 **Author:** [@nascode](https://github.com/nascode) **Created:** 6/24/2025 **Status:** ✅ Merged **Merged:** 7/5/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `fix/protocol-specific-wildcards` --- ### 📝 Commits (1) - [`4d0f01a`](https://github.com/better-auth/better-auth/commit/4d0f01a5d3cacab4af8d0501f0dee61e0d99b267) fix(origin-check): support protocol-specific wildcard trusted origins ### 📊 Changes **2 files changed** (+48 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/middlewares/origin-check.test.ts` (+38 -0) 📝 `packages/better-auth/src/api/middlewares/origin-check.ts` (+10 -0) </details> ### 📄 Description fix https://github.com/better-auth/better-auth/issues/3154 ## Summary The changes fix a bug where protocol-specific wildcard patterns like `https://*.example.com` do not work. This happen because there is a missing logic, if protocol is defined in wildcard trusted origins, we should consider entire url, not only the host to be matched. ## Changes made: 1. Fixed wildcard matching logic. 2. Added test coverage - New test case validates both positive and negative scenarios for protocol-specific wildcards. 3. Applied fix to both middleware functions - Both originCheckMiddleware and originCheck now handle protocol-specific wildcards correctly. --- <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 20:27:47 -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#21576