From 503a95987f48ee4123b8d2bb635fd6ee69ebb3c5 Mon Sep 17 00:00:00 2001
From: Mats <113344017+NitrinCloud@users.noreply.github.com>
Date: Sat, 19 Oct 2024 05:47:47 +0200
Subject: [PATCH] fix: fetch error on same app (#234)
---
docs/content/docs/integrations/nuxt.mdx | 6 ++++--
examples/nuxt-example/lib/auth-client.ts | 4 +---
packages/better-auth/src/client/vue.ts | 11 ++++++-----
3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/docs/content/docs/integrations/nuxt.mdx b/docs/content/docs/integrations/nuxt.mdx
index b9d47a90c8..a24b5ae146 100644
--- a/docs/content/docs/integrations/nuxt.mdx
+++ b/docs/content/docs/integrations/nuxt.mdx
@@ -41,7 +41,7 @@ export const authClient = createAuthClient({
```
Once you have created the client, you can use it to sign up, sign in, and perform other actions.
-Some of the actinos are reactive.
+Some of the actions are reactive.
### Example usage
@@ -72,9 +72,11 @@ const session = authClient.useSession()
If you are using Nuxt with SSR, you can use the `useSession` function in the `setup` function of your page component and pass `useFetch` to make it work with SSR.
+Note that you cannot pass a `baseURL` or `fetchOptions.baseURL` to the client while using the same nuxt app as a backend since it will throw a 401 on request using the complete url.
+
```vue title="index.vue"
diff --git a/examples/nuxt-example/lib/auth-client.ts b/examples/nuxt-example/lib/auth-client.ts
index 89fd967d5c..cf58d4a82b 100644
--- a/examples/nuxt-example/lib/auth-client.ts
+++ b/examples/nuxt-example/lib/auth-client.ts
@@ -1,8 +1,6 @@
import { createAuthClient } from "better-auth/vue";
-export const authClient = createAuthClient({
- baseURL: "http://localhost:3000",
-});
+export const authClient = createAuthClient();
export const {
signIn,
diff --git a/packages/better-auth/src/client/vue.ts b/packages/better-auth/src/client/vue.ts
index b751b5e53e..cd484c6001 100644
--- a/packages/better-auth/src/client/vue.ts
+++ b/packages/better-auth/src/client/vue.ts
@@ -12,7 +12,6 @@ import type {
import { createDynamicPathProxy } from "./proxy";
import { getSessionAtom } from "./session-atom";
import type { UnionToIntersection } from "../types/helper";
-import { getBaseURL } from "../utils/base-url";
function getAtomKey(str: string) {
return `use${capitalizeFirstLetter(str)}`;
@@ -77,10 +76,12 @@ export function createAuthClient