Files
jarv.is/lib/auth.ts
jakeandClaude Sonnet 5.5 ae2ab88988 fix: disable better-auth update-user endpoint
Names and avatars come from GitHub at sign-up; prevent signed-in users
from renaming themselves to impersonate other commenters.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-03 08:19:41 -04:00

44 lines
1.3 KiB
TypeScript

import { drizzleAdapter } from "@better-auth/drizzle-adapter/relations-v2";
import { dash } from "@better-auth/infra";
import { waitUntil } from "@vercel/functions";
import { type BetterAuthOptions, betterAuth } from "better-auth/minimal";
import { nextCookies } from "better-auth/next-js";
import { db } from "@/lib/db";
import * as schema from "@/lib/db/schema";
export const auth = betterAuth({
appName: "jarv.is",
baseURL: process.env.NEXT_PUBLIC_BASE_URL,
database: drizzleAdapter(db, {
provider: "pg",
schema,
}),
plugins: [dash(), nextCookies()],
// names and avatars come from GitHub at sign-up; don't let users rename themselves (e.g. to impersonate someone)
disabledPaths: ["/update-user"],
socialProviders: {
github: {
clientId: process.env.GITHUB_CLIENT_ID!,
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
mapProfileToUser: (profile) => ({
name: profile.login,
email: profile.email,
emailVerified: true,
image: profile.avatar_url,
}),
},
},
advanced: {
database: {
joins: true,
},
backgroundTasks: {
handler: waitUntil,
},
ipAddress: {
ipAddressHeaders: ["x-vercel-forwarded-for", "x-forwarded-for"],
},
},
} satisfies BetterAuthOptions);