Authenticated request with Expo

Hi everyone! I successfully integrated better-auth with expo and expressjs (email&password plugin). Now, i need to make authenticated request to my backend. How can I make that?
I tried using using authClient:

export const authClient = createAuthClient({
    baseURL: 'http://192.168.200.197:8000',
    plugins: [
        expoClient({
            scheme: 'MyWallet',
            storagePrefix: 'MyWallet',
            storage: SecureStore,
        }),
    ],
});

However when i make request with authClient.$fetch, for example to route /expenses, it automatically adds prefix to url, so it will become http://192.168.200.197:8000/api/auth/expenses, but on the backend the route is just /api/expenses.

I also tried making my own fetch client:
// token is from useSession()
if (token) {
            headers.append('Authorization', `Bearer ${token}`);
        }

        const response = await fetch(`${this.baseUrl}${endpoint}`, {
            ...options,
            credentials: 'include',
            headers,
        });


With that, backend returns me unauthenticated error. Also included express setup. Please help.
2025-04-15_20.01.52.png
Was this page helpful?