[PR #5248] [MERGED] fix: resolve custom URL scheme origin matching with wildcards #5880

Closed
opened 2026-03-13 12:40:00 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5248
Author: @AntonVishal
Created: 10/12/2025
Status: Merged
Merged: 10/15/2025
Merged by: @Bekacru

Base: canaryHead: fix/origin-check


📝 Commits (3)

  • d5d1704 fix: resolve custom URL scheme origin matching with wildcards
  • c18cef1 fix(docs): correct formatting of trusted origins in security documentation
  • 774dbf6 fix(docs): update comment formatting for browser extension in security documentation

📊 Changes

4 files changed (+83 additions, -4 deletions)

View changed files

📝 docs/content/docs/integrations/expo.mdx (+23 -2)
📝 docs/content/docs/reference/security.mdx (+3 -1)
📝 packages/better-auth/src/api/middlewares/origin-check.test.ts (+54 -0)
📝 packages/better-auth/src/utils/url.ts (+3 -1)

📄 Description

Closes https://github.com/better-auth/better-auth/issues/5231

Fixes wildcard pattern matching for custom URL schemes like exp:// in trustedOrigins. The URL API returns string "null" for custom schemes, preventing fallback logic from working correctly.

Updated the docs too:
Screenshot 2025-10-12 at 4 07 05 PM
Screenshot 2025-10-12 at 4 07 26 PM


Summary by cubic

Fix wildcard origin matching for custom URL schemes (exp://) in trustedOrigins so Expo dev links pass origin checks. Docs now include example patterns for local IP ranges.

  • Bug Fixes
    • Treat URL.origin === "null" as null in getOrigin to enable custom scheme wildcard matching.
    • Add tests for exp:// with 10.0.0., 192.168.., 172... ranges and rejection of unmatched IPs.

🔄 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/5248 **Author:** [@AntonVishal](https://github.com/AntonVishal) **Created:** 10/12/2025 **Status:** ✅ Merged **Merged:** 10/15/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/origin-check` --- ### 📝 Commits (3) - [`d5d1704`](https://github.com/better-auth/better-auth/commit/d5d170428f8a8ba2786a64ee25be7a0833e339f5) fix: resolve custom URL scheme origin matching with wildcards - [`c18cef1`](https://github.com/better-auth/better-auth/commit/c18cef1123b34eb8f525a07d6f97d7c80b1f23b8) fix(docs): correct formatting of trusted origins in security documentation - [`774dbf6`](https://github.com/better-auth/better-auth/commit/774dbf6e5e8f2386fe5afdb735fe37dd33730db0) fix(docs): update comment formatting for browser extension in security documentation ### 📊 Changes **4 files changed** (+83 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/integrations/expo.mdx` (+23 -2) 📝 `docs/content/docs/reference/security.mdx` (+3 -1) 📝 `packages/better-auth/src/api/middlewares/origin-check.test.ts` (+54 -0) 📝 `packages/better-auth/src/utils/url.ts` (+3 -1) </details> ### 📄 Description Closes https://github.com/better-auth/better-auth/issues/5231 Fixes wildcard pattern matching for custom URL schemes like exp:// in trustedOrigins. The URL API returns string "null" for custom schemes, preventing fallback logic from working correctly. Updated the docs too: <img width="814" height="306" alt="Screenshot 2025-10-12 at 4 07 05 PM" src="https://github.com/user-attachments/assets/befd8d17-d385-41b8-8e23-40c74eeda80e" /> <img width="782" height="577" alt="Screenshot 2025-10-12 at 4 07 26 PM" src="https://github.com/user-attachments/assets/2370f21a-5813-4cdd-83b0-23bfeceea176" /> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fix wildcard origin matching for custom URL schemes (exp://) in trustedOrigins so Expo dev links pass origin checks. Docs now include example patterns for local IP ranges. - **Bug Fixes** - Treat URL.origin === "null" as null in getOrigin to enable custom scheme wildcard matching. - Add tests for exp:// with 10.0.0.*, 192.168.*.*, 172.*.*.* ranges and rejection of unmatched IPs. <!-- 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-03-13 12:40:00 -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#5880