Skip to content

Commit 0f13219

Browse files
committed
fix: use srcDir/serverDir instead of hardcoded paths
1 parent c9d0432 commit 0f13219

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

docs/content/1.getting-started/3.configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default defineNuxtConfig({
3636

3737
## Server Configuration
3838

39-
The core of your authentication logic resides in `server/auth.config.ts`. This file allows you to configure Better Auth plugins, providers, and settings.
39+
The core of your authentication logic resides in `<serverDir>/auth.config.ts`. By default, this is `server/auth.config.ts`. This file allows you to configure Better Auth plugins, providers, and settings.
4040

4141
### defineServerAuth
4242

docs/content/1.getting-started/4.client-setup.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ description: Configure the client-side authentication client.
55

66
## Create the Client Factory
77

8-
Create a file at `app/auth.client.ts` (or `.js`) and export a `createAppAuthClient` function.
8+
Create a file at `<srcDir>/auth.client.ts` (or `.js`) and export a `createAppAuthClient` function.
9+
10+
- **Nuxt 4** (default): `app/auth.client.ts`
11+
- **Nuxt 3**: `auth.client.ts` (at project root)
912

1013
```ts [app/auth.client.ts]
1114
import { createAuthClient } from 'better-auth/vue'
@@ -28,7 +31,7 @@ This file is required because Better Auth plugins often have a client-side count
2831
2932
## Using Plugins
3033
31-
If you added a plugin in `server/auth.config.ts`, make sure to add its client equivalent here.
34+
If you added a plugin in your server config (`auth.config.ts`), make sure to add its client equivalent here.
3235
3336
```ts [app/auth.client.ts]
3437
import { createAuthClient } from 'better-auth/vue'

src/module.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ export default defineNuxtModule<BetterAuthModuleOptions>({
2121
async setup(options, nuxt) {
2222
const resolver = createResolver(import.meta.url)
2323

24-
const serverConfigPath = resolver.resolve(nuxt.options.rootDir, 'server/auth.config')
25-
const clientConfigPath = resolver.resolve(nuxt.options.rootDir, 'app/auth.client')
24+
const serverConfigPath = resolver.resolve(nuxt.options.serverDir, 'auth.config')
25+
const clientConfigPath = resolver.resolve(nuxt.options.srcDir, 'auth.client')
2626

2727
const serverConfigExists = existsSync(`${serverConfigPath}.ts`) || existsSync(`${serverConfigPath}.js`)
2828
const clientConfigExists = existsSync(`${clientConfigPath}.ts`) || existsSync(`${clientConfigPath}.js`)
2929

3030
if (!serverConfigExists)
31-
throw new Error('[@onmax/nuxt-better-auth] Missing server/auth.config.ts - create with defineServerAuth()')
31+
throw new Error(`[@onmax/nuxt-better-auth] Missing ${serverConfigPath}.ts - create with defineServerAuth()`)
3232
if (!clientConfigExists)
33-
throw new Error('[@onmax/nuxt-better-auth] Missing app/auth.client.ts - export createAppAuthClient()')
33+
throw new Error(`[@onmax/nuxt-better-auth] Missing ${clientConfigPath}.ts - export createAppAuthClient()`)
3434

3535
const hub = (nuxt.options as unknown as Record<string, unknown>).hub as { db?: boolean | string | object, kv?: boolean } | undefined
3636
const hasDb = !!hub?.db

0 commit comments

Comments
 (0)