mirror of
https://github.com/Comfy-Org/Comfy-PR.git
synced 2026-11-04 23:37:33 +00:00
[PR #88] feat: migrate from NextAuth to Better Auth #88
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/Comfy-PR#88
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Comfy-Org/Comfy-PR/pull/88
Author: @snomiao
Created: 10/20/2025
Status: 🔄 Open
Base:
main← Head:sno-better-auth📝 Commits (10+)
2a25dd5feat: migrate from NextAuth to Better Auth4a0d9d4fix: update import paths and fix headers in getAuthUser8304618fix: correct better-auth integration issuesf785396fix: ensure type safety in getAuthUser without using 'as any'7d3e350fix: add null checks for user in auth-protected pagesffac697fix: add backward compatibility for NextAuth environment variables6939f22fix: remove conflicting NextAuth route and fix Better Auth API endpointdd2c3aafix: add CORS support and fix MongoDB adapter for Better Auth89f5957fix: type assertion for MongoDB adapter compatibilityae0923cfix: address PR review comments - improve type safety and env var handling📊 Changes
18 files changed (+425 additions, -159 deletions)
View changed files
📝
.env.example(+19 -0)➕
MIGRATION.md(+122 -0)📝
app/(dashboard)/followup/actions/send-gmail/page.tsx(+7 -11)📝
app/(dashboard)/rules/layout.tsx(+2 -2)➕
app/api/auth/[...all]/route.ts(+4 -0)➖
app/api/auth/[...nextauth]/Users.tsx(+0 -12)➖
app/api/auth/[...nextauth]/auth.ts(+0 -23)➖
app/api/auth/[...nextauth]/getAuthUser.tsx(+0 -19)➖
app/api/auth/[...nextauth]/route.ts(+0 -2)➖
app/auth/login/page-bak.tsx(+0 -30)📝
app/auth/login/page.tsx(+4 -6)📝
app/tasks/github-action-update/actions.tsx(+1 -1)📝
app/tasks/github-action-update/page.tsx(+2 -2)📝
bun.lock(+118 -51)➕
lib/auth-client.ts(+36 -0)➕
lib/auth.ts(+64 -0)➕
lib/getAuthUser.ts(+45 -0)📝
package.json(+1 -0)📄 Description
Summary
This PR migrates the authentication system from NextAuth v5 to Better Auth, a more modern and actively maintained authentication library.
Changes Made
New Files
lib/auth.ts: Better Auth server configuration with MongoDB adapterlib/auth-client.ts: Client-side auth exports (signIn,signOut,useSession)lib/getAuthUser.ts: Migrated auth user utility with Better Auth session APIapp/api/auth/[...all]/route.ts: Better Auth API route handlerMIGRATION.md: Comprehensive migration documentationModified Files
app/auth/login/page.tsx: Updated to use Better Auth client methods.env.example: Added Better Auth environment variable documentationpackage.json: Addedbetter-auth@^1.3.28dependencyFeatures Preserved
Test Plan
Breaking Changes
API Changes
Session Object Structure: Better Auth may have a different session object structure. All places where
session.useris accessed should be reviewed.Server-side Session Access:
Client-side Sign In:
Environment Variables
Better Auth uses the same OAuth provider environment variables as NextAuth:
AUTH_GITHUB_ID/AUTH_GITHUB_SECRETAUTH_GOOGLE_ID/AUTH_GOOGLE_SECRETAdditional optional variables:
BETTER_AUTH_SECRET- Session encryption keyBETTER_AUTH_URL- Application base URLNEXT_PUBLIC_APP_URL- Public URL for client-side authNext Steps
app/api/auth/[...nextauth]/auth.tsapp/api/auth/[...nextauth]/route.tsapp/api/auth/[...nextauth]/getAuthUser.tsxapp/api/auth/[...nextauth]/Users.tsxnext-authfrom dependenciesDocumentation
See MIGRATION.md for detailed migration documentation including rollback plan.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.