[GH-ISSUE #3086] callbackURL do not support wildcard trustedOrigins #26792

Closed
opened 2026-04-17 17:29:50 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @ImSingee on GitHub (Jun 19, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3086

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Set trustedOrigins option to ["https://*.example.com"]

Call

await authClient.signIn.magicLink({
  email: "user@email.com",
  callbackURL: "https://xxx.example.com/dashboard",
});

Current vs. Expected behavior

The following error will occur

{"code":"INVALID_CALLBACKURL","message":"Invalid callbackURL"}

What version of Better Auth are you using?

1.2.9

Provide environment information

N/A

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)


Additional context

The origin-check middleware supports wildcards:

https://github.com/better-auth/better-auth/blob/v1.2.9/packages/better-auth/src/api/middlewares/origin-check.ts#L47-L52

But checkCallbackURL doesn't:

https://github.com/better-auth/better-auth/blob/v1.2.9/packages/better-auth/src/utils/callback-url.ts#L14

Originally created by @ImSingee on GitHub (Jun 19, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3086 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Set `trustedOrigins` option to `["https://*.example.com"]` Call ``` await authClient.signIn.magicLink({ email: "user@email.com", callbackURL: "https://xxx.example.com/dashboard", }); ``` ### Current vs. Expected behavior The following error will occur ```json {"code":"INVALID_CALLBACKURL","message":"Invalid callbackURL"} ``` ### What version of Better Auth are you using? 1.2.9 ### Provide environment information ```bash N/A ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript ``` ### Additional context The origin-check middleware supports wildcards: https://github.com/better-auth/better-auth/blob/v1.2.9/packages/better-auth/src/api/middlewares/origin-check.ts#L47-L52 But checkCallbackURL doesn't: https://github.com/better-auth/better-auth/blob/v1.2.9/packages/better-auth/src/utils/callback-url.ts#L14
GiteaMirror added the lockedbug labels 2026-04-17 17:29:50 -05:00
Author
Owner

@Bekacru commented on GitHub (Jul 17, 2025):

check callback url isn't actually used by any of the origin checkers. Make sure you're on latest and you have the right configuration of for origins list and it should work

<!-- gh-comment-id:3084712939 --> @Bekacru commented on GitHub (Jul 17, 2025): check callback url isn't actually used by any of the origin checkers. Make sure you're on latest and you have the right configuration of for origins list and it should work
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#26792