[GH-ISSUE #1645] All $fetch requests are prepended with /api/auth #26172

Closed
opened 2026-04-17 16:39:14 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @wharacembell on GitHub (Mar 2, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1645

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

I am using better auth with expo and hono, and the authentication flow is working, but when trying to make fetch requests using the library's $fetch, the path of all requests are prepended with /api/auth .

Current vs. Expected behavior

When calling $fetch("/test") it should resolve to baseUrl/test not baseUrl/api/auth/test

What version of Better Auth are you using?

1.2 and the previous versions

Provide environment information

Expo dev build

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

Client

Auth config (if applicable)

import { createAuthClient } from "better-auth/react";
import { expoClient } from "@better-auth/expo/client";
import * as SecureStore from "expo-secure-store";

export const authClient = createAuthClient({
  baseURL:
    process.env.EXPO_PUBLIC_API_URL /* base url of your Better Auth backend. */,
  plugins: [
    expoClient({
      scheme: "myapp",
      storagePrefix: "myapp",
      storage: SecureStore,
    }),
  ],
  storage: SecureStore,
});

Additional context

No response

Originally created by @wharacembell on GitHub (Mar 2, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1645 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce I am using better auth with expo and hono, and the authentication flow is working, but when trying to make fetch requests using the library's $fetch, the path of all requests are prepended with /api/auth . ### Current vs. Expected behavior When calling $fetch("/test") it should resolve to baseUrl/test not baseUrl/api/auth/test ### What version of Better Auth are you using? 1.2 and the previous versions ### Provide environment information ```bash Expo dev build ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript import { createAuthClient } from "better-auth/react"; import { expoClient } from "@better-auth/expo/client"; import * as SecureStore from "expo-secure-store"; export const authClient = createAuthClient({ baseURL: process.env.EXPO_PUBLIC_API_URL /* base url of your Better Auth backend. */, plugins: [ expoClient({ scheme: "myapp", storagePrefix: "myapp", storage: SecureStore, }), ], storage: SecureStore, }); ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-17 16:39:15 -05:00
Author
Owner

@ahmedivy commented on GitHub (Mar 3, 2025):

Yes, same issue with me

<!-- gh-comment-id:2694050808 --> @ahmedivy commented on GitHub (Mar 3, 2025): Yes, same issue with me
Author
Owner

@awesomepandapig commented on GitHub (Mar 5, 2025):

Same issue here.

Notably it's also ignoring the baseURL entirely and sending requests to the wrong subdomain!
example.com/api/auth when it should be sending to api.example.com/auth

<!-- gh-comment-id:2700344057 --> @awesomepandapig commented on GitHub (Mar 5, 2025): Same issue here. Notably it's also ignoring the baseURL entirely and sending requests to the wrong subdomain! `example.com/api/auth` when it should be sending to `api.example.com/auth`
Author
Owner

@juan-altatech commented on GitHub (Mar 30, 2025):

still an issue

<!-- gh-comment-id:2764689684 --> @juan-altatech commented on GitHub (Mar 30, 2025): still an issue
Author
Owner

@Bekacru commented on GitHub (Apr 12, 2025):

We're going to remove the recommendation to use $fetch. The /api/auth prefix is intentional - the real issue is that we're suggesting using $fech api in the docs

<!-- gh-comment-id:2799046499 --> @Bekacru commented on GitHub (Apr 12, 2025): We're going to remove the recommendation to use `$fetch`. The `/api/auth` prefix is intentional - the real issue is that we're suggesting using $fech api in the docs
Author
Owner

@Bekacru commented on GitHub (Apr 12, 2025):

if you want to use better fetch check its docs https://better-fetch.vercel.app/

<!-- gh-comment-id:2799046698 --> @Bekacru commented on GitHub (Apr 12, 2025): if you want to use better fetch check its docs https://better-fetch.vercel.app/
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#26172