mirror of
https://github.com/lobehub/lobehub.git
synced 2026-09-20 04:56:13 +08:00
191f3fe776
* 📝 docs: fix outdated content across the docs site Audited docs/ against the current codebase and fixed stale content that drifted after major refactors (Clerk/NextAuth → Better Auth, src/server → apps/server, src/{config,envs,locales} → packages/*, model-bank updates). - self-hosting/auth: mark removed NextAuth/Clerk pages with deprecation warnings; fix microsoft/zitadel alias claims and the Logto callback path - environment-variables & advanced: correct wrong defaults (S3_SET_ACL, AI_IMAGE_DEFAULT_IMAGE_NUM, index/proxy URLs), drop non-existent env vars and fictional feature flags, fix OIDC config guidance - development: update refactored paths, Better Auth, .mjs configs, remove the MSW section (msw is not a dependency) - providers & model examples: replace retired model ids with in-bank ones; fix comfyui frontmatter corruption - usage: rename Moderator→Orchestrator, GTD→Task, correct shortcut keys, channel capability tables, Feishu/Lark WebSocket mode - platform/migration: fix dead links, docker service name, npx/npm → bun EN and zh-CN pairs updated together. * 📝 docs: fix Logto callback path and AUTH_SECRET deprecation guidance - Revert Logto/Sealos callback URLs to /api/auth/callback/logto to match the runtime SSO redirectURI override - Narrow legacy auth Callout: AUTH_SECRET remains required for Better Auth; mark NEXT_AUTH_SECRET as deprecated in zh-CN * 📝 docs: refresh agent skills for locales, env, auth, and agentRun paths Align OSS agent guidance with post-refactor layout: - packages/locales/src/default + bun run i18n - packages/env/src for env schemas (@/envs alias) - spa-auth shell + src/routes/auth segments - chat agentRun/transports/hetero instead of aiChat * 📝 docs: document APP_URL as required for Better Auth base URL Self-hosted auth uses appEnv.APP_URL as baseURL, not request-header auto-detection. NEXT_PUBLIC_AUTH_URL remains deprecated. * 📝 docs: note self-host search provider setup for web search Built-in lobe-web-browsing needs no client plugin, but self-hosted servers still require SEARCH_PROVIDERS / SEARXNG_URL (default SearXNG). * 📝 docs: point feature guide welcome UI at AgentHome Opening message/questions on the agent chat page live in src/features/AgentHome, not Onboarding WelcomeMessage.
67 lines
3.0 KiB
Plaintext
67 lines
3.0 KiB
Plaintext
---
|
|
title: Configure Clerk Authentication Service - Step-by-Step Guide
|
|
description: >-
|
|
Learn how to set up Clerk authentication with environment variables and
|
|
webhooks.
|
|
tags:
|
|
- Clerk Authentication
|
|
- Environment Variables
|
|
- Webhook Configuration
|
|
---
|
|
|
|
# Configure Clerk Authentication Service
|
|
|
|
<Callout type={'warning'}>
|
|
Clerk has been fully removed from LobeHub. Setting any `CLERK_*` environment variable will cause the deployment to fail at build/startup. This page is kept for historical reference only — please follow the [Clerk to Better Auth migration guide](/docs/self-hosting/migration/v2/auth/clerk-to-betterauth).
|
|
</Callout>
|
|
|
|
Go to [Clerk](https://clerk.com?utm_source=lobehub\&utm_medium=docs) to register and create an application to obtain the corresponding Public Key and Secret Key.
|
|
|
|
## Get Environment Variables
|
|
|
|
<Steps>
|
|
### Add Public and Private Key Environment Variables
|
|
|
|
Add `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` and `CLERK_SECRET_KEY` environment variables. You can click on the "API Keys" in the menu and copy the corresponding values to get these environment variables.
|
|
|
|
<Image alt={'Find the corresponding public and private key environment variables in Clerk'} src={'/blog/assets28616219/89883703-7a1a-4a11-b944-5d804544e57c.webp'} />
|
|
|
|
The environment variables required for this step are as follows:
|
|
|
|
```shell
|
|
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_live_xxxxxxxxxxx
|
|
CLERK_SECRET_KEY=sk_live_xxxxxxxxxxxxxxxxxxxxxx
|
|
NEXT_PUBLIC_ENABLE_NEXT_AUTH=0
|
|
```
|
|
|
|
### Create and Configure Webhook in Clerk
|
|
|
|
Since we let Clerk fully handle user authentication and management, we need Clerk to notify our application and store the changes in the user lifecycle (create, update, delete). We achieve this by using the Webhook provided by Clerk.
|
|
|
|
We need to add an endpoint in Clerk's Webhooks to inform Clerk to send notifications to this endpoint when a user's information changes.
|
|
|
|
<Image alt={'Add Webhooks endpoint in Clerk'} src={'/blog/assets28616219/f50f47fb-5e8e-4930-bf4e-8cf6f5b8afb9.webp'} />
|
|
|
|
Fill in your project URL in the endpoint, such as `https://your-project.com/api/webhooks/clerk`. Then, subscribe to events by checking the three user events (`user.created`, `user.deleted`, `user.updated`), and click create.
|
|
|
|
<Callout type={'warning'}>
|
|
The `https://` in the URL is essential to maintain the integrity of the URL.
|
|
</Callout>
|
|
|
|
<Image alt={'Configure URL and user events when adding Clerk Webhooks'} src={'/blog/assets28616219/0249ea56-ab17-4aa9-a56c-9ebd556c2645.webp'} />
|
|
|
|
### Add Webhook Secret to Environment Variables
|
|
|
|
After creating, you can find the secret of this Webhook in the bottom right corner:
|
|
|
|
<Image alt={'View Clerk Webhooks secret'} src={'/blog/assets28616219/fab4abb2-584b-49de-9340-813382951635.webp'} />
|
|
|
|
The environment variable corresponding to this secret is `CLERK_WEBHOOK_SECRET`:
|
|
|
|
```shell
|
|
CLERK_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxx
|
|
```
|
|
</Steps>
|
|
|
|
By following these steps, you have successfully configured the Clerk authentication service.
|