Al.exe
Al.exe
BABetter Auth
Created by Al.exe on 3/26/2025 in #help
Conflict between Admin and Anonymous plugins – 500 error
I started a project from scratch
9 replies
BABetter Auth
Created by Al.exe on 3/26/2025 in #help
Conflict between Admin and Anonymous plugins – 500 error
No description
9 replies
BABetter Auth
Created by Al.exe on 3/26/2025 in #help
Conflict between Admin and Anonymous plugins – 500 error
For the moment they are commented And I call it in the layout:
/*
'use client'

// --- Dependencies ---
import { useEffect } from 'react'
import { signIn, authClient } from '@/lib/auth-client'*/

// --- Components: Layout ---
import Header from '@/components/layout/header'
import Footer from '@/components/layout/footer'

// --- Layout:Space ---
export default function HomeLayout({
children
}: Readonly<{ children: React.ReactNode }>) {
/*useEffect(() => {
;(async () => {
const { data, error } = await signIn.anonymous()
console.log('DATA', data)
console.log('ERROR', error)
})()
}, [])*/

// --- Render ---
return (
<div className="relative w-full overflow-x-hidden">
<Header />
<div className="pt-14">{children}</div>
<Footer />
</div>
)
}
/*
'use client'

// --- Dependencies ---
import { useEffect } from 'react'
import { signIn, authClient } from '@/lib/auth-client'*/

// --- Components: Layout ---
import Header from '@/components/layout/header'
import Footer from '@/components/layout/footer'

// --- Layout:Space ---
export default function HomeLayout({
children
}: Readonly<{ children: React.ReactNode }>) {
/*useEffect(() => {
;(async () => {
const { data, error } = await signIn.anonymous()
console.log('DATA', data)
console.log('ERROR', error)
})()
}, [])*/

// --- Render ---
return (
<div className="relative w-full overflow-x-hidden">
<Header />
<div className="pt-14">{children}</div>
<Footer />
</div>
)
}
9 replies
BABetter Auth
Created by Al.exe on 3/26/2025 in #help
Conflict between Admin and Anonymous plugins – 500 error
Yes, of course, in auth.ts:
export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: 'postgresql'
}),
user: {
additionalFields: {
role: {
type: 'string'
},
plan: {
type: 'string'
}
}
},
socialProviders: {
// --- Google
},
plugins: [
magicLink({
sendMagicLink: async ({ email, url }) => {
// --- Send email
}
}),
stripe({
stripeClient,
stripeWebhookSecret: env.STRIPE_WEBHOOK_SECRET,
createCustomerOnSignUp: true,
subscription: {}
}),
/*anonymous({
emailDomainName: env.RESEND_DOMAIN
}),*/
customSession(async ({ user, session }) => {
// --- Fetch User ---
const userNew = await prisma.user.findUnique({
where: {
id: user.id
}
})

// --- Return ---
return {
session,
user: {
...user,
...userNew
}
}
}),
admin()
]
})
export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: 'postgresql'
}),
user: {
additionalFields: {
role: {
type: 'string'
},
plan: {
type: 'string'
}
}
},
socialProviders: {
// --- Google
},
plugins: [
magicLink({
sendMagicLink: async ({ email, url }) => {
// --- Send email
}
}),
stripe({
stripeClient,
stripeWebhookSecret: env.STRIPE_WEBHOOK_SECRET,
createCustomerOnSignUp: true,
subscription: {}
}),
/*anonymous({
emailDomainName: env.RESEND_DOMAIN
}),*/
customSession(async ({ user, session }) => {
// --- Fetch User ---
const userNew = await prisma.user.findUnique({
where: {
id: user.id
}
})

// --- Return ---
return {
session,
user: {
...user,
...userNew
}
}
}),
admin()
]
})
and in authClient:
import {
magicLinkClient,
customSessionClient,
//anonymousClient,
adminClient
} from 'better-auth/client/plugins'

// --- Auth Client ---
export const authClient = createAuthClient({
plugins: [
magicLinkClient(),
//anonymousClient(),
customSessionClient<typeof auth>(),
stripeClient({
subscription: true
}),
adminClient()
]
})
import {
magicLinkClient,
customSessionClient,
//anonymousClient,
adminClient
} from 'better-auth/client/plugins'

// --- Auth Client ---
export const authClient = createAuthClient({
plugins: [
magicLinkClient(),
//anonymousClient(),
customSessionClient<typeof auth>(),
stripeClient({
subscription: true
}),
adminClient()
]
})
9 replies