Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions playground/app/auth.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createAuthClient } from 'better-auth/vue'
import { defineClientAuth } from '@onmax/nuxt-better-auth/config'

export function createAppAuthClient(baseURL: string) {
return createAuthClient({ baseURL })
}
export default defineClientAuth(() => ({
baseURL: `${import.meta.env.VITE_CONVEX_SITE_URL}/api/auth`,
}))
6 changes: 6 additions & 0 deletions playground/convex/auth.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { AuthConfig } from 'convex/server'
import { getAuthConfigProvider } from '@convex-dev/better-auth/auth-config'

export default {
providers: [getAuthConfigProvider()],
} satisfies AuthConfig
44 changes: 44 additions & 0 deletions playground/convex/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type { GenericCtx } from '@convex-dev/better-auth'
import type { BetterAuthOptions } from 'better-auth/minimal'
import type { DataModel } from './_generated/dataModel'
import process from 'node:process'
import { createClient } from '@convex-dev/better-auth'
import { convex, crossDomain } from '@convex-dev/better-auth/plugins'
import { betterAuth } from 'better-auth/minimal'
import { components } from './_generated/api'
import authConfig from './auth.config'

const siteUrl = process.env.SITE_URL!

export const authComponent = createClient<DataModel>(components.betterAuth, {
verbose: false,
})

export function createAuthOptions(ctx: GenericCtx<DataModel>): BetterAuthOptions {
return ({
appName: 'nuxt-convex Playground',
trustedOrigins: [siteUrl, 'https://*.onmax.me'],
database: authComponent.adapter(ctx),
socialProviders: {
github: {
clientId: process.env.GITHUB_CLIENT_ID || '',
clientSecret: process.env.GITHUB_CLIENT_SECRET || '',
},
},
session: {
cookieCache: { enabled: true, maxAge: 7 * 24 * 60 * 60, strategy: 'jwe' },
},
account: {
storeStateStrategy: 'cookie',
storeAccountCookie: true,
},
plugins: [
crossDomain({ siteUrl }),
convex({ authConfig }),
],
}) satisfies BetterAuthOptions
}

export function createAuth(ctx: GenericCtx<DataModel>): ReturnType<typeof betterAuth> {
return betterAuth(createAuthOptions(ctx))
}
6 changes: 6 additions & 0 deletions playground/convex/convex.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import betterAuth from '@convex-dev/better-auth/convex.config'
import { defineApp } from 'convex/server'

const app = defineApp()
app.use(betterAuth)
export default app
8 changes: 8 additions & 0 deletions playground/convex/http.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { httpRouter } from 'convex/server'
import { authComponent, createAuth } from './auth'

const http = httpRouter()

authComponent.registerRoutes(http, createAuth, { cors: true })

export default http
1 change: 1 addition & 0 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default defineNuxtConfig({
},

auth: {
clientOnly: true,
redirects: {
login: '/',
guest: '/',
Expand Down
1 change: 1 addition & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"build": "nuxi build"
},
"dependencies": {
"@convex-dev/better-auth": "catalog:convex",
"@nuxthub/core": "catalog:playground",
"@onmax/nuxt-better-auth": "catalog:playground",
"better-auth": "catalog:playground",
Expand Down
19 changes: 0 additions & 19 deletions playground/server/auth.config.ts

This file was deleted.

2,007 changes: 1,881 additions & 126 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ catalogs:
'@nuxt/module-builder': ^1.0.2
typescript: ^5.9.3
convex:
'@convex-dev/better-auth': ^0.10.10
convex: ^1.31.3
lint:
'@antfu/eslint-config': ^6.7.3
Expand All @@ -36,7 +37,7 @@ catalogs:
vue: ^3.5.26
playground:
'@nuxthub/core': ^0.10.3
'@onmax/nuxt-better-auth': https://pkg.pr.new/onmax/nuxt-better-auth/@onmax/nuxt-better-auth@5f06fbf
'@onmax/nuxt-better-auth': ^0.0.2-alpha.15
better-auth: ^1.4.7
wrangler: ^4.0.0
prod:
Expand Down
Loading