Auth actions such as signIn don't support full URLs #623

Closed
opened 2026-03-13 07:57:26 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @shadiramadan on GitHub (Feb 4, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

        await authClient.signIn.email({
          email,
          password,
          callbackURL: "https://google.com",  // example URL
        });

Error in response:

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

Current vs. Expected behavior

callbackURLs should support ANY URL and should be URL encoded automatically. I've tried encoding them myself and they just error.

What version of Better Auth are you using?

1.1.15

Provide environment information

macOS / Chrome

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

Client

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

I run better-auth in it's own Next App (which took a bit to figure out btw w/ prisma types...)

I'd like to support external callbackURLs and a consistent API for callbacks, additionally I'd like separate callbacks for success or error.

Originally created by @shadiramadan on GitHub (Feb 4, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce ```typescript await authClient.signIn.email({ email, password, callbackURL: "https://google.com", // example URL }); ``` Error in response: ```json {"message":"Invalid callbackURL","code":"INVALID_CALLBACKURL"} ``` ### Current vs. Expected behavior callbackURLs should support ANY URL and should be URL encoded automatically. I've tried encoding them myself and they just error. ### What version of Better Auth are you using? 1.1.15 ### Provide environment information ```bash macOS / Chrome ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context I run better-auth in it's own Next App (which took a bit to figure out btw w/ prisma types...) I'd like to support external callbackURLs and a consistent API for callbacks, additionally I'd like separate callbacks for success or error.
GiteaMirror added the bug label 2026-03-13 07:57:26 -05:00
Author
Owner

@Bekacru commented on GitHub (Feb 4, 2025):

The error occurs because we don't allow arbitrary URLs as callback destinations, as that would make the endpoint vulnerable to open redirects. You can add the allowed origins to the trustedOrigins list in your auth config and that should work.

@Bekacru commented on GitHub (Feb 4, 2025): The error occurs because we don't allow arbitrary URLs as callback destinations, as that would make the endpoint vulnerable to open redirects. You can add the allowed origins to the `trustedOrigins` list in your auth config and that should work.
Author
Owner

@shadiramadan commented on GitHub (Feb 5, 2025):

I confirm properly setting trustedOrigins resolves my issue, haven't tested wildcards yet but hopefully they are golden! Closing this issue.

@shadiramadan commented on GitHub (Feb 5, 2025): I confirm properly setting `trustedOrigins` resolves my issue, haven't tested wildcards yet but hopefully they are golden! Closing this issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#623