Skip to content

♻️ refactor: remove Clerk authentication code#11711

Merged
tjx666 merged 22 commits intonextfrom
refactor/remove-clerk-code
Jan 23, 2026
Merged

♻️ refactor: remove Clerk authentication code#11711
tjx666 merged 22 commits intonextfrom
refactor/remove-clerk-code

Conversation

@tjx666
Copy link
Copy Markdown
Member

@tjx666 tjx666 commented Jan 22, 2026

Summary

  • Remove all Clerk authentication related code from the codebase
  • Better Auth is now the primary authentication solution
  • Add deprecation check for Clerk environment variables at build time and Docker startup
  • Keep migration scripts in scripts/clerk-to-betterauth/ for users migrating from Clerk

Test plan

  • Verify build succeeds without Clerk dependencies
  • Test Better Auth login flow works correctly
  • Test Next Auth login flow works correctly
  • Verify Clerk env var detection blocks deployment with clear error message

@vercel
Copy link
Copy Markdown

vercel bot commented Jan 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
lobehub Ready Ready Preview, Comment Jan 23, 2026 7:14am

Request Review

@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Jan 22, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @tjx666, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@gru-agent
Copy link
Copy Markdown
Contributor

gru-agent bot commented Jan 22, 2026

There is too much information in the pull request to test.

@tjx666 tjx666 added trigger:build-docker Trigger Docker image build trigger:build-desktop Trigger Desktop build labels Jan 22, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.15%. Comparing base (fe093bd) to head (d3f60d7).
⚠️ Report is 8 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next   #11711      +/-   ##
==========================================
- Coverage   74.18%   74.15%   -0.03%     
==========================================
  Files        1194     1191       -3     
  Lines       95149    94818     -331     
  Branches    10521    12931    +2410     
==========================================
- Hits        70587    70316     -271     
+ Misses      24472    24412      -60     
  Partials       90       90              
Flag Coverage Δ
app 67.17% <100.00%> (-0.08%) ⬇️
database 91.44% <ø> (ø)
packages/agent-runtime 90.20% <ø> (ø)
packages/context-engine 85.39% <ø> (ø)
packages/conversation-flow 92.28% <ø> (ø)
packages/file-loaders 88.66% <ø> (ø)
packages/memory-user-memory 69.68% <ø> (ø)
packages/model-bank 100.00% <ø> (ø)
packages/model-runtime 86.72% <ø> (ø)
packages/prompts 79.33% <ø> (ø)
packages/python-interpreter 92.90% <ø> (ø)
packages/ssrf-safe-fetch 0.00% <ø> (ø)
packages/utils 93.22% <100.00%> (-0.04%) ⬇️
packages/web-crawler 95.62% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Store 67.95% <ø> (-0.07%) ⬇️
Services 50.58% <ø> (-0.02%) ⬇️
Server 67.71% <ø> (-0.10%) ⬇️
Libs 40.36% <ø> (-0.78%) ⬇️
Utils 93.60% <ø> (-0.22%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45a460759b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines -21 to -24
const Page = () => {
if (!enableClerk) return notFound();

return <SignIn path="/login" />;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep /login route or redirect to /signin

Removing the /login page here drops the only handler for that path, but other parts of the app still link to /login (e.g. src/app/[variants]/share/t/[id]/_layout/index.tsx and src/app/[variants]/share/t/[id]/index.tsx). Without a redirect to /signin, users following those links now hit a 404 after this commit. Consider adding a redirect or updating those links.

Useful? React with 👍 / 👎.

@tjx666 tjx666 force-pushed the refactor/remove-clerk-code branch from 0beac50 to 7f0ac0b Compare January 22, 2026 14:19
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 22, 2026

🐳 Database Docker Build Completed!

Version: pr-refactor-remove-clerk-code-395595a2c
Build Time: 2026-01-23T07:25:20.876Z
🔗 View all tags on Docker Hub: https://hub.docker.com/r/lobehub/lobehub/tags

Pull Image

Download the Docker image to your local machine:

docker pull lobehub/lobehub:pr-refactor-remove-clerk-code-395595a2c

Important

This build is for testing and validation purposes.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 22, 2026

🚀 Desktop App Build Completed!

Version: 0.0.0-nightly.pr11711.4103
Build Time: 2026-01-23T07:57:01.064Z

📦 View All Build Artifacts

Build Artifacts

Platform File Size
macOS (Apple Silicon) LobeHub-Nightly-0.0.0-nightly.pr11711.4103-arm64.dmg 106.04 MB
macOS (Intel) LobeHub-Nightly-0.0.0-nightly.pr11711.4103-x64.dmg 111.12 MB
Windows LobeHub-Nightly-0.0.0-nightly.pr11711.4103-setup.exe 103.46 MB
Linux LobeHub-Nightly-0.0.0-nightly.pr11711.4103.AppImage 126.25 MB

Warning

Note: This is a temporary build for testing purposes only.

tjx666 added 14 commits January 23, 2026 10:46
- Remove Clerk SDK dependencies (@clerk/nextjs, @clerk/themes, @clerk/localizations)
- Delete Clerk auth provider, webhook handler, and related components
- Remove enableClerk feature flag and related environment variables
- Clean up Clerk-specific i18n files (locales/*/clerk.json)
- Remove InvalidClerkUser error type
- Simplify middleware to use local createRouteMatcher implementation
- Update user router to remove Clerk webhook retry logic
- Clean up all test files that mocked Clerk functionality
- Add /signup to public routes for Better Auth

Better Auth is now the sole authentication solution.
- Remove @clerk/backend dependency from migration scripts
- Define native TypeScript types for Clerk API responses
- Use direct fetch calls to Clerk REST API endpoints
…check

- Remove Clerk references from tests, scripts, and documentation
- Add Clerk env var detection in prebuild and Docker startup
- Update README to feature Better Auth as primary auth solution
- Remove Clerk-related electron workflow modifiers
- Simplify createRouteMatcher regex conversion logic
- Extract shared checkDeprecatedClerkEnv function to scripts/_shared/
- Update Dockerfile to copy _shared directory for Docker runtime
- Add comment for Better Auth login page check
- Ignore unicorn/no-process-exit and prefer-top-level-await for scripts/
Redirect old Clerk login route to Better Auth signin for backward compatibility.
Escape all special regex chars (including parentheses) before restoring
(.*) to wildcard. Previous order caused patterns like /share(.*) to be
converted to literal match instead of wildcard.
- Extract createRouteMatcher to separate module for better testability
- Add comprehensive tests covering exact paths, wildcards, and edge cases
- Update share page links from /login to /signin
- Update robots.txt disallow list
- Remove /login from middleware matcher (redirect handles it)
Use FluentEmoji and custom styles instead of antd Result component
for 401/403/404 error states to maintain consistent design language.

Closes LOBE-3418
@tjx666 tjx666 force-pushed the refactor/remove-clerk-code branch from e2668fb to 2c643a3 Compare January 23, 2026 02:52
- Remove NEXT_PUBLIC_ENABLE_BETTER_AUTH flag (no longer needed)
- Set enableBetterAuth = !enableNextAuth (default to Better Auth)
- Set enableAuth = true (always enabled)
- Update Dockerfile to default NEXT_PUBLIC_ENABLE_NEXT_AUTH to 0
Auth is now always enabled by default, so the enableAuth flag is no longer needed.
Better Auth requires APP_URL to recognize localhost as a trusted origin.
Without this, login fails with "Invalid origin" error in E2E tests.
Prevents dynamic import of @/auth module which doesn't exist in test environment.
Add explicit createdAt timestamps to ensure deterministic message ordering.
Without timestamps, message order depends on database insertion order which
is non-deterministic.
@tjx666 tjx666 merged commit 395595a into next Jan 23, 2026
40 of 43 checks passed
@tjx666 tjx666 deleted the refactor/remove-clerk-code branch January 23, 2026 06:41
@lobehubbot
Copy link
Copy Markdown
Member

❤️ Great PR @tjx666 ❤️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.

lobehubbot pushed a commit that referenced this pull request Jan 23, 2026
## [Version&nbsp;2.0.0-next.345](v2.0.0-next.344...v2.0.0-next.345)
<sup>Released on **2026-01-23**</sup>

#### ✨ Features

- **misc**: Remove Clerk authentication code.

#### 🐛 Bug Fixes

- **misc**: Slove the agents header switch agents the lobeAI not show problem.

#### 💄 Styles

- **misc**: Improve auto scroll and group profile.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's improved

* **misc**: Remove Clerk authentication code, closes [#11711](#11711) ([395595a](395595a))

#### What's fixed

* **misc**: Slove the agents header switch agents the lobeAI not show problem, closes [#11726](#11726) ([f45f508](f45f508))

#### Styles

* **misc**: Improve auto scroll and group profile, closes [#11725](#11725) ([550acc2](550acc2))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
@lobehubbot
Copy link
Copy Markdown
Member

🎉 This PR is included in version 2.0.0-next.345 🎉

The release is available on:

Your semantic-release bot 📦🚀

JamieStivala pushed a commit to jaworldwideorg/OneJA-Bot that referenced this pull request Jan 23, 2026
## [Version&nbsp;1.153.0](v1.152.0...v1.153.0)
<sup>Released on **2026-01-23**</sup>

#### ♻ Code Refactoring

- **auth**: Remove NEXT_PUBLIC_AUTH_URL env variable.
- **model-select**: Migrate FunctionCallingModelSelect to LobeSelect.
- **ModelSwitchPanel**: Migrate from Popover to DropdownMenu with virtual scrolling.
- **userMemories**: Removed un-used code.
- **misc**: Improve memory data with experience and identity, move vercel-react-best-practices skills to .agents directory.

#### ✨ Features

- **database**: Added user memory activity.
- **desktop**: Add legacy local database detection and migration guidance.
- **misc**: Add platform-aware download client menu option, add server version check for desktop app, remove Clerk authentication code, skill setting page and skill store, support agent group unpublish agents, support client tasks mode, update the sandbox preinstall libs in sys role.

#### 🐛 Bug Fixes

- **copilot**: Pass correct scope when creating new session in PageEditor.
- **desktop**: Gracefully handle missing update manifest 404 errors.
- **model-runtime**: Filter unsupported image types (SVG) before sending to vision models.
- **pdf**: Upgrade pdfjs-dist and react-pdf to v5.x.
- **sidebar-drawer**: Fix drawer positioning and title style.
- **misc**: Fix group broadcast trigger tool use, fix local system tools, fix memory schema, fix multi agent tasks issue, fix multi tasks no summary issue, fix scope issue, fix tool argument scape and improve multi task run, fixed the sandbox tools call when error should use right callback, improve e2e server and complete i18n resources, slove the agent group editor not focus in editdata area, slove the agents header switch agents the lobeAI not show problem, sloved the old removeSessionTopics not work, TypewriterEffect not refreshing on language change, updata cron job ui & fixed commnuity pagenation goto error, update the agentbuilder tools not always use humanIntervention.

#### 💄 Styles

- **misc**: Improve auto scroll and group profile, update og, update share style.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

* **auth**: Remove NEXT_PUBLIC_AUTH_URL env variable, closes [lobehub#11658](https://github.com/jaworldwideorg/OneJA-Bot/issues/11658) ([c0f9875](c0f9875))
* **model-select**: Migrate FunctionCallingModelSelect to LobeSelect, closes [lobehub#11664](https://github.com/jaworldwideorg/OneJA-Bot/issues/11664) ([ad51305](ad51305))
* **ModelSwitchPanel**: Migrate from Popover to DropdownMenu with virtual scrolling, closes [lobehub#11663](https://github.com/jaworldwideorg/OneJA-Bot/issues/11663) ([c9d9dff](c9d9dff))
* **userMemories**: Removed un-used code, closes [lobehub#11713](https://github.com/jaworldwideorg/OneJA-Bot/issues/11713) ([89750fc](89750fc))
* **misc**: Improve memory data with experience and identity, closes [lobehub#11717](https://github.com/jaworldwideorg/OneJA-Bot/issues/11717) ([bdb3eb4](bdb3eb4))
* **misc**: Move vercel-react-best-practices skills to .agents directory, closes [lobehub#11703](https://github.com/jaworldwideorg/OneJA-Bot/issues/11703) ([6df7731](6df7731))

#### What's improved

* **database**: Added user memory activity, closes [lobehub#11680](https://github.com/jaworldwideorg/OneJA-Bot/issues/11680) ([0160fbd](0160fbd))
* **desktop**: Add legacy local database detection and migration guidance, closes [lobehub#11682](https://github.com/jaworldwideorg/OneJA-Bot/issues/11682) ([5664b84](5664b84))
* **misc**: Add platform-aware download client menu option, closes [lobehub#11676](https://github.com/jaworldwideorg/OneJA-Bot/issues/11676) ([55abddc](55abddc))
* **misc**: Add server version check for desktop app, closes [lobehub#11710](https://github.com/jaworldwideorg/OneJA-Bot/issues/11710) ([0cf2723](0cf2723))
* **misc**: Remove Clerk authentication code, closes [lobehub#11711](https://github.com/jaworldwideorg/OneJA-Bot/issues/11711) ([395595a](395595a))
* **misc**: Skill setting page and skill store, closes [lobehub#11665](https://github.com/jaworldwideorg/OneJA-Bot/issues/11665) ([d8c0c26](d8c0c26))
* **misc**: Support agent group unpublish agents, closes [lobehub#11687](https://github.com/jaworldwideorg/OneJA-Bot/issues/11687) ([4e060be](4e060be))
* **misc**: Support client tasks mode, closes [lobehub#11666](https://github.com/jaworldwideorg/OneJA-Bot/issues/11666) ([98cf57b](98cf57b))
* **misc**: Update the sandbox preinstall libs in sys role, closes [lobehub#11688](https://github.com/jaworldwideorg/OneJA-Bot/issues/11688) ([404c577](404c577))

#### What's fixed

* **copilot**: Pass correct scope when creating new session in PageEditor, closes [lobehub#11714](https://github.com/jaworldwideorg/OneJA-Bot/issues/11714) ([0259270](0259270))
* **desktop**: Gracefully handle missing update manifest 404 errors, closes [lobehub#11625](https://github.com/jaworldwideorg/OneJA-Bot/issues/11625) ([13e95b9](13e95b9))
* **model-runtime**: Filter unsupported image types (SVG) before sending to vision models, closes [lobehub#11698](https://github.com/jaworldwideorg/OneJA-Bot/issues/11698) ([c0c99a7](c0c99a7))
* **pdf**: Upgrade pdfjs-dist and react-pdf to v5.x, closes [lobehub#11686](https://github.com/jaworldwideorg/OneJA-Bot/issues/11686) ([2b620df](2b620df))
* **sidebar-drawer**: Fix drawer positioning and title style, closes [lobehub#11655](https://github.com/jaworldwideorg/OneJA-Bot/issues/11655) ([cf5320e](cf5320e))
* **misc**: Fix group broadcast trigger tool use, closes [lobehub#11646](https://github.com/jaworldwideorg/OneJA-Bot/issues/11646) ([831a9b3](831a9b3))
* **misc**: Fix local system tools, closes [lobehub#11702](https://github.com/jaworldwideorg/OneJA-Bot/issues/11702) ([6548fc7](6548fc7))
* **misc**: Fix memory schema, closes [lobehub#11645](https://github.com/jaworldwideorg/OneJA-Bot/issues/11645) ([3baf780](3baf780))
* **misc**: Fix multi agent tasks issue, closes [lobehub#11672](https://github.com/jaworldwideorg/OneJA-Bot/issues/11672) ([9de773b](9de773b))
* **misc**: Fix multi tasks no summary issue, closes [lobehub#11685](https://github.com/jaworldwideorg/OneJA-Bot/issues/11685) ([26ce317](26ce317))
* **misc**: Fix scope issue, closes [lobehub#11719](https://github.com/jaworldwideorg/OneJA-Bot/issues/11719) ([17adde8](17adde8))
* **misc**: Fix tool argument scape and improve multi task run, closes [lobehub#11691](https://github.com/jaworldwideorg/OneJA-Bot/issues/11691) ([b13bb8a](b13bb8a))
* **misc**: Fixed the sandbox tools call when error should use right callback, closes [lobehub#11721](https://github.com/jaworldwideorg/OneJA-Bot/issues/11721) ([e8fce68](e8fce68))
* **misc**: Improve e2e server and complete i18n resources, closes [lobehub#11678](https://github.com/jaworldwideorg/OneJA-Bot/issues/11678) ([d450dd9](d450dd9))
* **misc**: Slove the agent group editor not focus in editdata area, closes [lobehub#11677](https://github.com/jaworldwideorg/OneJA-Bot/issues/11677) ([9ac84e6](9ac84e6))
* **misc**: Slove the agents header switch agents the lobeAI not show problem, closes [lobehub#11726](https://github.com/jaworldwideorg/OneJA-Bot/issues/11726) ([f45f508](f45f508))
* **misc**: Sloved the old removeSessionTopics not work, closes [lobehub#11671](https://github.com/jaworldwideorg/OneJA-Bot/issues/11671) ([06d41e5](06d41e5))
* **misc**: TypewriterEffect not refreshing on language change, closes [lobehub#11657](https://github.com/jaworldwideorg/OneJA-Bot/issues/11657) ([ba30f46](ba30f46))
* **misc**: Updata cron job ui & fixed commnuity pagenation goto error, closes [lobehub#11700](https://github.com/jaworldwideorg/OneJA-Bot/issues/11700) ([42ad2a0](42ad2a0))
* **misc**: Update the agentbuilder tools not always use humanIntervention, closes [lobehub#11696](https://github.com/jaworldwideorg/OneJA-Bot/issues/11696) ([0d3017b](0d3017b))

#### Styles

* **misc**: Improve auto scroll and group profile, closes [lobehub#11725](https://github.com/jaworldwideorg/OneJA-Bot/issues/11725) ([550acc2](550acc2))
* **misc**: Update og, closes [lobehub#11709](https://github.com/jaworldwideorg/OneJA-Bot/issues/11709) ([01cf4e4](01cf4e4))
* **misc**: Update share style, closes [lobehub#11716](https://github.com/jaworldwideorg/OneJA-Bot/issues/11716) ([3c70dfa](3c70dfa))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released on @next size:XXL This PR changes 1000+ lines, ignoring generated files. trigger:build-desktop Trigger Desktop build trigger:build-docker Trigger Docker image build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants