[GH-ISSUE #1560] TypeError: Invalid URL #26143

Closed
opened 2026-04-17 16:35:34 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @MadadiSaeed on GitHub (Feb 24, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1560

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

I have a very simple starter project with Remix & Cloudflare.

Current vs. Expected behavior

I have this client code:

import { createAuthClient } from "better-auth/react";

export const { signIn, signUp, useSession, sendVerificationEmail } = createAuthClient();

Unfortunately when I import useSession hook in my client component and use it I get this error:
TypeError: Invalid URL /get-session. Are you passing in a relative URL but not setting the baseURL?
I thought it is not required to set baseURL. So is this a bug or I am missing somthing here?

What version of Better Auth are you using?

1.1.19

Provide environment information

- OS: Linux
- Browser: Google Chrome

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

Client

Auth config (if applicable)


Additional context

when using signIn and signUp functions every thing is OK but using useSession throws this TypeError.

Pass the base URL of your auth server. If the auth server is running on the same domain as your client, you can skip this step.

So my auth server is running on the same domain as my client but why I am getting this error? By setting the baseURL everything is OK.

Originally created by @MadadiSaeed on GitHub (Feb 24, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1560 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce I have a very simple starter project with Remix & Cloudflare. ### Current vs. Expected behavior I have this client code: ``` import { createAuthClient } from "better-auth/react"; export const { signIn, signUp, useSession, sendVerificationEmail } = createAuthClient(); ``` Unfortunately when I import `useSession` hook in my client component and use it I get this error: `TypeError: Invalid URL /get-session. Are you passing in a relative URL but not setting the baseURL?` I thought it is not required to set `baseURL`. So is this a bug or I am missing somthing here? ### What version of Better Auth are you using? 1.1.19 ### Provide environment information ```bash - OS: Linux - Browser: Google Chrome ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript ``` ### Additional context when using `signIn` and `signUp` functions every thing is OK but using `useSession` throws this `TypeError`. > Pass the base URL of your auth server. If the auth server is running on the same domain as your client, you can skip this step. So my auth server is running on the same domain as my client but why I am getting this error? By setting the `baseURL` everything is OK.
GiteaMirror added the lockedbug labels 2026-04-17 16:35:34 -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#26143