@lobehub/chat 0.126.0 → 0.126.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +8 -8
  3. package/README.zh-CN.md +8 -8
  4. package/docs/Deployment/Authentication.md +8 -0
  5. package/docs/Deployment/Authentication.zh-CN.md +9 -1
  6. package/docs/Deployment/Environment-Variable.md +11 -3
  7. package/docs/Deployment/Environment-Variable.zh-CN.md +11 -3
  8. package/docs/Development/{Authentication.md → Add-New-Authentication-Providers.md} +1 -1
  9. package/docs/Development/{Authentication.zh-CN.md → Add-New-Authentication-Providers.zh-CN.md} +1 -1
  10. package/docs/Home.md +2 -0
  11. package/docs/_Sidebar.md +2 -0
  12. package/next.config.mjs +3 -0
  13. package/package.json +1 -1
  14. package/src/app/api/auth/next-auth.ts +25 -0
  15. package/src/app/chat/features/ChatHeader/ShareButton/style.ts +3 -1
  16. package/src/app/chat/features/TopicListContent/Topic/index.tsx +2 -1
  17. package/src/app/layout.tsx +5 -0
  18. package/src/app/market/features/ShareAgentButton/Inner.tsx +2 -2
  19. package/src/app/metadata.ts +6 -1
  20. package/src/app/settings/common/Common.tsx +4 -3
  21. package/src/config/client.ts +1 -0
  22. package/src/config/server/app.ts +1 -0
  23. package/src/const/url.ts +4 -0
  24. package/src/features/AgentSetting/AgentConfig/index.tsx +3 -2
  25. package/src/hooks/useSTT.ts +2 -2
  26. package/src/hooks/useTTS.ts +3 -3
  27. package/src/layout/GlobalLayout/index.tsx +17 -4
  28. package/src/middleware.ts +1 -1
  29. package/src/services/_url.ts +30 -11
  30. package/src/services/chat.ts +3 -3
  31. package/src/services/file.ts +3 -2
  32. package/src/services/global.ts +3 -2
  33. package/src/services/imageGeneration.ts +3 -2
  34. package/src/services/market.ts +4 -3
  35. package/src/services/plugin.ts +4 -3
  36. package/src/store/chat/slices/tool/action.ts +0 -3
  37. package/src/utils/basePath.ts +3 -0
  38. package/src/app/api/oauth/next-auth.ts +0 -21
  39. /package/src/app/api/{oauth → auth}/[...nextauth]/route.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.126.2](https://github.com/lobehub/lobe-chat/compare/v0.126.1...v0.126.2)
6
+
7
+ <sup>Released on **2024-02-09**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix OAuth throws an error on Vercel deploy.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix OAuth throws an error on Vercel deploy, closes [#1278](https://github.com/lobehub/lobe-chat/issues/1278) [#1277](https://github.com/lobehub/lobe-chat/issues/1277) [#1274](https://github.com/lobehub/lobe-chat/issues/1274) ([81d2d76](https://github.com/lobehub/lobe-chat/commit/81d2d76))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
30
+ ### [Version 0.126.1](https://github.com/lobehub/lobe-chat/compare/v0.126.0...v0.126.1)
31
+
32
+ <sup>Released on **2024-02-09**</sup>
33
+
34
+ #### 🐛 Bug Fixes
35
+
36
+ - **misc**: Add basePath to support subdirectory.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### What's fixed
44
+
45
+ - **misc**: Add basePath to support subdirectory, closes [#1179](https://github.com/lobehub/lobe-chat/issues/1179) ([43e544a](https://github.com/lobehub/lobe-chat/commit/43e544a))
46
+
47
+ </details>
48
+
49
+ <div align="right">
50
+
51
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
52
+
53
+ </div>
54
+
5
55
  ## [Version 0.126.0](https://github.com/lobehub/lobe-chat/compare/v0.125.0...v0.126.0)
6
56
 
7
57
  <sup>Released on **2024-02-09**</sup>
package/README.md CHANGED
@@ -225,14 +225,14 @@ Our marketplace is not just a showcase platform but also a collaborative space.
225
225
 
226
226
  <!-- AGENT LIST -->
227
227
 
228
- | Recent Submits | Description |
229
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
230
- | [Jira Story Facilitator](https://chat-preview.lobehub.com/market?agent=jira-product-manager)<br/><sup>By **[emad-pg](https://github.com/emad-pg)** on **2024-02-07**</sup> | A Product manager agent that is specialised in transforming feature ideas into comprehensive Jira stories drafts for your team to pick up.<br/>`product-management` `story-creation` `jira` |
231
- | [Text Variator](https://chat-preview.lobehub.com/market?agent=text-variator)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-07**</sup> | Please provide the text you would like me to generate different versions of<br/>`copywriting` `editing` `creative-writing` |
232
- | [Turkish/English Translator](https://chat-preview.lobehub.com/market?agent=turkish-english-translator)<br/><sup>By **[Zisan-uzum](https://github.com/Zisan-uzum)** on **2024-02-07**</sup> | Translates text into Turkish or English, as needed<br/>`turkish` `english` `translation` `writing` |
233
- | [CAN: Code Master](https://chat-preview.lobehub.com/market?agent=can)<br/><sup>By **[MrHuangJser](https://github.com/MrHuangJser)** on **2024-02-06**</sup> | CAN: Professional coding expert with years of experience and no character limit. Provides entrepreneurial services such as creative naming, slogans, user profiles, pain points, value propositions, sales channels, revenue streams, and cost structures.<br/>`coding` `communication` `questioning` |
234
-
235
- > 📊 Total agents: [<kbd>**159**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
228
+ | Recent Submits | Description |
229
+ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
230
+ | [Vocabulary Wizard](https://chat-preview.lobehub.com/market?agent=awl-vocab-wizard)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | Expert in generating vocabulary lists and MCQ tests<br/>`vocabulary` `academic-word-list` `language-learning` `testing` |
231
+ | [English Proficiency Evaluator](https://chat-preview.lobehub.com/market?agent=english-proficiency-assessor)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | Expert in creating adaptive English proficiency diagnostic tests<br/>`test-creation` `english-proficiency` `assessment` |
232
+ | [Glossary Generator](https://chat-preview.lobehub.com/market?agent=glossary-generator)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | Expert in generating glossaries with English definitions and example sentences<br/>`glossary` `translation` `language` |
233
+ | [Grammar Worksheet Creator](https://chat-preview.lobehub.com/market?agent=grammar-revision-worksheets)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | Specializes in creating English grammar learning materials and exercises<br/>`english-grammar` `worksheet` `learning` `practice` `mc-qs` |
234
+
235
+ > 📊 Total agents: [<kbd>**170**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
236
236
 
237
237
  <!-- AGENT LIST -->
238
238
 
package/README.zh-CN.md CHANGED
@@ -205,14 +205,14 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
205
205
 
206
206
  <!-- AGENT LIST -->
207
207
 
208
- | 最近新增 | 助手说明 |
209
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
210
- | [Jira 故事协助工具](https://chat-preview.lobehub.com/market?agent=jira-product-manager)<br/><sup>By **[emad-pg](https://github.com/emad-pg)** on **2024-02-07**</sup> | 一款专门将功能点子转化为全面的 Jira 故事草稿,供团队选择的产品经理代理。<br/>`产品管理` `故事创建` `jira` |
211
- | [文本变体生成器](https://chat-preview.lobehub.com/market?agent=text-variator)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-07**</sup> | 请提供您希望我生成不同版本的文本<br/>`文案撰写` `编辑` `创意写作` |
212
- | [土耳其语 / 英语翻译器](https://chat-preview.lobehub.com/market?agent=turkish-english-translator)<br/><sup>By **[Zisan-uzum](https://github.com/Zisan-uzum)** on **2024-02-07**</sup> | 根据需要将文本翻译成土耳其语或英语<br/>`土耳其语` `英语` `翻译` `写作` |
213
- | [CAN: 编程大师](https://chat-preview.lobehub.com/market?agent=can)<br/><sup>By **[MrHuangJser](https://github.com/MrHuangJser)** on **2024-02-06**</sup> | CAN: 专业编程专家,多年经验,无字符限制。提供创意命名、标语、用户画像、痛点、价值主张、销售渠道、收入流、成本结构等创业计划服务。<br/>`编程` `交流` `提问` |
214
-
215
- > 📊 Total agents: [<kbd>**159**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
208
+ | 最近新增 | 助手说明 |
209
+ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
210
+ | [词汇大师](https://chat-preview.lobehub.com/market?agent=awl-vocab-wizard)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | 擅长生成词汇列表和多项选择测试<br/>`词汇` `学术词汇表` `语言学习` `测试` |
211
+ | [英语熟练度评估器](https://chat-preview.lobehub.com/market?agent=english-proficiency-assessor)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | 专业创建自适应英语熟练度诊断测试的专家<br/>`测试创建` `英语熟练度` `评估` |
212
+ | [术语表生成器](https://chat-preview.lobehub.com/market?agent=glossary-generator)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | 擅长生成带有英文定义和例句的术语表<br/>`术语表` `翻译` `语言` |
213
+ | [语法工作表生成器](https://chat-preview.lobehub.com/market?agent=grammar-revision-worksheets)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | 专注于创建英语语法学习材料和练习<br/>`english-grammar` `worksheet` `learning` `practice` `mc-qs` |
214
+
215
+ > 📊 Total agents: [<kbd>**170**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
216
216
 
217
217
  <!-- AGENT LIST -->
218
218
 
@@ -24,6 +24,14 @@ Once the application is successfully created, click on the respective applicatio
24
24
 
25
25
  ![](https://github.com/CloudPassenger/lobe-chat/assets/30863298/a1ed996b-95ef-4b7d-a50d-b4666eccfecb)
26
26
 
27
+ On the application configuration page, you also need to configure the **_Allowed Callback URLs_** to be `http(s)://<your-domain>/api/auth/callback/auth0`
28
+
29
+ ![](https://github.com/CloudPassenger/lobe-chat/assets/30863298/575f46aa-f485-49bd-8b90-dbb1ce1a5c1b)
30
+
31
+ > \[!NOTE]
32
+ >
33
+ > You can fill in or modify the Allowed Callback URLs after deployment, but make sure the URLs are consistent with the deployed URLs!
34
+
27
35
  ## Adding Users
28
36
 
29
37
  Navigate to the **_Users Management_** section in the left sidebar to access the user management interface. You can create new users for your organization to log in to LobeChat.
@@ -1,6 +1,6 @@
1
1
  # 身份验证服务
2
2
 
3
- LobeChat 支持配置外部身份验证服务,供企业 / 组织内部使用,统一管理用户授权,目前支持 [Auth0][auth0-client-page] 本文将介绍如何配置身份验证服务。
3
+ LobeChat 支持配置外部身份验证服务,供企业 / 组织内部使用,统一管理用户授权,目前支持 [Auth0][auth0-client-page],本文将介绍如何配置身份验证服务。
4
4
 
5
5
  ### TOC
6
6
 
@@ -24,6 +24,14 @@ LobeChat 支持配置外部身份验证服务,供企业 / 组织内部使用
24
24
 
25
25
  ![](https://github.com/CloudPassenger/lobe-chat/assets/30863298/a1ed996b-95ef-4b7d-a50d-b4666eccfecb)
26
26
 
27
+ 在应用配置页面中,还需要配置 Allowed Callback URLs,在此处填写 `http(s)://<your-domain>/api/auth/callback/auth0`
28
+
29
+ ![](https://github.com/CloudPassenger/lobe-chat/assets/30863298/575f46aa-f485-49bd-8b90-dbb1ce1a5c1b)
30
+
31
+ > \[!NOTE]
32
+ >
33
+ > 可以在部署后再填写或修改 Allowed Callback URLs,但是务必保证填写的 URL 与部署的 URL 一致
34
+
27
35
  ## 新增用户
28
36
 
29
37
  点击左侧导航栏的「Users Management」,进入用户管理界面,可以为你的组织新建用户,用以登录 LobeChat
@@ -7,6 +7,7 @@ LobeChat provides additional configuration options during deployment, which can
7
7
  - [General Variables](#general-variables)
8
8
  - [`ACCESS_CODE`](#access_code)
9
9
  - [`ENABLE_OAUTH_SSO`](#enable_oauth_sso)
10
+ - [`NEXT_PUBLIC_BASE_PATH`](#next_public_base_path)
10
11
  - [Authentication Service Providers](#authentication-service-providers)
11
12
  - [Common Settings](#common-settings)
12
13
  - [Auth0](#auth0)
@@ -41,7 +42,14 @@ LobeChat provides additional configuration options during deployment, which can
41
42
  - Type: Optional
42
43
  - Description: Enable OAuth single sign-on (SSO) for LobeChat. Set to `1` to enable OAuth SSO. See [Authentication Service Providers](#authentication-service-providers) for more details.
43
44
  - Default: `-`
44
- - Example: `1` or `0`
45
+ - Example: `1`
46
+
47
+ ### `NEXT_PUBLIC_BASE_PATH`
48
+
49
+ - Type:Optional
50
+ - Description:add `basePath` for LobeChat
51
+ - Default: `-`
52
+ - Example: `/test`
45
53
 
46
54
  ## Authentication Service Providers
47
55
 
@@ -56,7 +64,7 @@ LobeChat provides additional configuration options during deployment, which can
56
64
 
57
65
  ### Auth0
58
66
 
59
- > !\[NOTE]
67
+ > \[!NOTE]
60
68
  >
61
69
  > We only support the Auth0 authentication service provider at the moment. If you need to use other authentication service providers, you can submit a feature request or pull request.
62
70
 
@@ -99,7 +107,7 @@ LobeChat provides additional configuration options during deployment, which can
99
107
  - Default: `https://api.openai.com/v1`
100
108
  - Example: `https://api.chatanywhere.cn` or `https://aihubmix.com/v1`
101
109
 
102
- > !\[NOTE]
110
+ > \[!NOTE]
103
111
  >
104
112
  > Please check the request suffix of your proxy service provider. Some proxy service providers may add `/v1` to the request suffix, while others may not.
105
113
  > If you find that the AI returns an empty message during testing, try adding the `/v1` suffix and retrying.
@@ -7,6 +7,7 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
7
7
  - [通用变量](#通用变量)
8
8
  - [`ACCESS_CODE`](#access_code)
9
9
  - [`ENABLE_OAUTH_SSO`](#enable_oauth_sso)
10
+ - [`NEXT_PUBLIC_BASE_PATH`](#next_public_base_path)
10
11
  - [身份验证服务](#身份验证服务)
11
12
  - [通用设置](#通用设置)
12
13
  - [Auth0](#auth0)
@@ -41,7 +42,14 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
41
42
  - 类型:可选
42
43
  - 描述:为 LobeChat 启用单点登录 (SSO)。设置为 `1` 以启用单点登录。有关详细信息,请参阅[身份验证服务](#身份验证服务)。
43
44
  - 默认值: `-`
44
- - 示例: `1` 或 `0`
45
+ - 示例: `1`
46
+
47
+ ### `NEXT_PUBLIC_BASE_PATH`
48
+
49
+ - 类型:可选
50
+ - 描述:为 LobeChat 添加 `basePath`
51
+ - 默认值: `-`
52
+ - 示例: `/test`
45
53
 
46
54
  ## 身份验证服务
47
55
 
@@ -56,7 +64,7 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
56
64
 
57
65
  ### Auth0
58
66
 
59
- > !\[NOTE] 注意事项:
67
+ > \[!NOTE] 注意事项:
60
68
  >
61
69
  > 目前我们只支持 Auth0 身份验证服务提供商。如果您需要使用其他身份验证服务提供商,可以提交功能请求或 Pull Request。
62
70
 
@@ -99,7 +107,7 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
99
107
  - 默认值:`https://api.openai.com/v1`
100
108
  - 示例:`https://api.chatanywhere.cn` 或 `https://aihubmix.com/v1`
101
109
 
102
- > !\[NOTE] 注意事项:
110
+ > \[!NOTE] 注意事项:
103
111
  >
104
112
  > 请检查你的代理服务商的请求后缀,有的代理服务商会在请求后缀添加 `/v1`,有的则不会。
105
113
  > 如果你在测试时发现 AI 返回的消息为空,请尝试添加 `/v1` 后缀后重试。
@@ -23,7 +23,7 @@ Next, I will use [Okta](https://authjs.dev/reference/core/providers/okta) as an
23
23
 
24
24
  ### Step 1: Add Authenticator Core Code
25
25
 
26
- Open the `src/app/api/oauth/next-auth.ts` file and import `next-auth/providers/okta`.
26
+ Open the `src/app/api/auth/next-auth.ts` file and import `next-auth/providers/okta`.
27
27
 
28
28
  ```ts
29
29
  import { NextAuth } from 'next-auth';
@@ -23,7 +23,7 @@ LobeChat 使用 [Auth.js v5](https://authjs.dev/) 作为外部身份验证服务
23
23
 
24
24
  ### 步骤 1: 新增关键代码
25
25
 
26
- 打开 `src/app/api/oauth/next-auth.ts` 文件,引入 `next-auth/providers/okta`
26
+ 打开 `src/app/api/auth/next-auth.ts` 文件,引入 `next-auth/providers/okta`
27
27
 
28
28
  ```ts
29
29
  import { NextAuth } from 'next-auth';
package/docs/Home.md CHANGED
@@ -27,6 +27,7 @@ LobeChat is a open-source, extensible ([Function Calling][fc-url]), high-perform
27
27
  - [Docker Deployment Guide](https://github.com/lobehub/lobe-chat/wiki/Docker-Deployment) | [Docker 部署指引](https://github.com/lobehub/lobe-chat/wiki/Docker-Deployment.zh-CN)
28
28
  - [Deploying with Azure OpenAI](https://github.com/lobehub/lobe-chat/wiki/Deploy-with-Azure-OpenAI) | [使用 Azure OpenAI 部署](https://github.com/lobehub/lobe-chat/wiki/Deploy-with-Azure-OpenAI.zh-CN)
29
29
  - [Environment Variables](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable) | [环境变量](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable.zh-CN)
30
+ - [Authentication Service](https://github.com/lobehub/lobe-chat/wiki/Authentication) | [身份验证服务](https://github.com/lobehub/lobe-chat/wiki/Authentication.zh-CN)
30
31
  - [Upstream Sync](https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync) | [自部署保持更新](https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync.zh-CN)
31
32
  - [Frequently Asked Questions](https://github.com/lobehub/lobe-chat/wiki/Common-Error) | [常见问题](https://github.com/lobehub/lobe-chat/wiki/Common-Error.zh-CN)
32
33
  - [Data Statistics](https://github.com/lobehub/lobe-chat/wiki/Analytics) | [数据统计](https://github.com/lobehub/lobe-chat/wiki/Analytics.zh-CN)
@@ -47,6 +48,7 @@ LobeChat is a open-source, extensible ([Function Calling][fc-url]), high-perform
47
48
  - [Frontend](https://github.com/lobehub/lobe-chat/wiki/Feature-Development-Frontend) | [前端实现](https://github.com/lobehub/lobe-chat/wiki/Feature-Development-Frontend.zh-CN)
48
49
  - [Internationalization Implementation Guide](https://github.com/lobehub/lobe-chat/wiki/Internationalization-Implementation) | [国际化实现指南](https://github.com/lobehub/lobe-chat/wiki/Internationalization-Implementation.zh-CN)
49
50
  - [New Locale Guide](https://github.com/lobehub/lobe-chat/wiki/Add-New-Locale) | [新语种添加指南](https://github.com/lobehub/lobe-chat/wiki/Add-New-Locale.zh-CN)
51
+ - [New Authentication Provider Guide](https://github.com/lobehub/lobe-chat/wiki/Add-New-Authentication-Providers) | [新身份验证方式开发指南](https://github.com/lobehub/lobe-chat/wiki/Add-New-Authentication-Providers.zh-CN)
50
52
  - [Testing Guide](https://github.com/lobehub/lobe-chat/wiki/Test) | [测试指南](https://github.com/lobehub/lobe-chat/wiki/Test.zh-CN)
51
53
  - [Resources and References](https://github.com/lobehub/lobe-chat/wiki/Resources) | [资源与参考](https://github.com/lobehub/lobe-chat/wiki/Resources.zh-CN)
52
54
 
package/docs/_Sidebar.md CHANGED
@@ -17,6 +17,7 @@
17
17
  - [Docker Deployment Guide](https://github.com/lobehub/lobe-chat/wiki/Docker-Deployment) | [Docker 部署指引](https://github.com/lobehub/lobe-chat/wiki/Docker-Deployment.zh-CN)
18
18
  - [Deploying with Azure OpenAI](https://github.com/lobehub/lobe-chat/wiki/Deploy-with-Azure-OpenAI) | [使用 Azure OpenAI 部署](https://github.com/lobehub/lobe-chat/wiki/Deploy-with-Azure-OpenAI.zh-CN)
19
19
  - [Environment Variables](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable) | [环境变量](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable.zh-CN)
20
+ - [Authentication Service](https://github.com/lobehub/lobe-chat/wiki/Authentication) | [身份验证服务](https://github.com/lobehub/lobe-chat/wiki/Authentication.zh-CN)
20
21
  - [Upstream Sync](https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync) | [自部署保持更新](https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync.zh-CN)
21
22
  - [Frequently Asked Questions](https://github.com/lobehub/lobe-chat/wiki/Common-Error) | [常见问题](https://github.com/lobehub/lobe-chat/wiki/Common-Error.zh-CN)
22
23
  - [Data Statistics](https://github.com/lobehub/lobe-chat/wiki/Analytics) | [数据统计](https://github.com/lobehub/lobe-chat/wiki/Analytics.zh-CN)
@@ -35,6 +36,7 @@
35
36
  - [Frontend](https://github.com/lobehub/lobe-chat/wiki/Feature-Development-Frontend) | [前端实现](https://github.com/lobehub/lobe-chat/wiki/Feature-Development-Frontend.zh-CN)
36
37
  - [Internationalization Implementation Guide](https://github.com/lobehub/lobe-chat/wiki/Internationalization-Implementation) | [国际化实现指南](https://github.com/lobehub/lobe-chat/wiki/Internationalization-Implementation.zh-CN)
37
38
  - [New Locale Guide](https://github.com/lobehub/lobe-chat/wiki/Add-New-Locale) | [新语种添加指南](https://github.com/lobehub/lobe-chat/wiki/Add-New-Locale.zh-CN)
39
+ - [New Authentication Provider Guide](https://github.com/lobehub/lobe-chat/wiki/Add-New-Authentication-Providers) | [新身份验证方式开发指南](https://github.com/lobehub/lobe-chat/wiki/Add-New-Authentication-Providers.zh-CN)
38
40
  - [Testing Guide](https://github.com/lobehub/lobe-chat/wiki/Test) | [测试指南](https://github.com/lobehub/lobe-chat/wiki/Test.zh-CN)
39
41
  - [Resources and References](https://github.com/lobehub/lobe-chat/wiki/Resources) | [资源与参考](https://github.com/lobehub/lobe-chat/wiki/Resources.zh-CN)
40
42
 
package/next.config.mjs CHANGED
@@ -7,6 +7,8 @@ const buildWithDocker = process.env.DOCKER === 'true';
7
7
  // if you need to proxy the api endpoint to remote server
8
8
  const API_PROXY_ENDPOINT = process.env.API_PROXY_ENDPOINT || '';
9
9
 
10
+ const basePath = process.env.NEXT_PUBLIC_BASE_PATH;
11
+
10
12
  const withBundleAnalyzer = analyzer({
11
13
  enabled: process.env.ANALYZE === 'true',
12
14
  });
@@ -22,6 +24,7 @@ const withPWA = nextPWA({
22
24
  /** @type {import('next').NextConfig} */
23
25
  const nextConfig = {
24
26
  compress: isProd,
27
+ basePath,
25
28
  experimental: {
26
29
  optimizePackageImports: [
27
30
  'emoji-mart',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.126.0",
3
+ "version": "0.126.2",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -0,0 +1,25 @@
1
+ import NextAuth from 'next-auth';
2
+ import Auth0 from 'next-auth/providers/auth0';
3
+
4
+ import { getServerConfig } from '@/config/server';
5
+
6
+ const { AUTH0_CLIENT_ID, ENABLE_OAUTH_SSO, AUTH0_CLIENT_SECRET, AUTH0_ISSUER, NEXTAUTH_SECRET } =
7
+ getServerConfig();
8
+
9
+ const nextAuth = NextAuth({
10
+ providers: ENABLE_OAUTH_SSO
11
+ ? [
12
+ Auth0({
13
+ clientId: AUTH0_CLIENT_ID,
14
+ clientSecret: AUTH0_CLIENT_SECRET,
15
+ issuer: AUTH0_ISSUER,
16
+ }),
17
+ ]
18
+ : [],
19
+ secret: NEXTAUTH_SECRET,
20
+ });
21
+
22
+ export const {
23
+ handlers: { GET, POST },
24
+ auth,
25
+ } = nextAuth;
@@ -1,11 +1,13 @@
1
1
  import { createStyles } from 'antd-style';
2
2
 
3
+ import { imageUrl } from '@/const/url';
4
+
3
5
  export const useStyles = createStyles(({ css, token, stylish, cx }, withBackground: boolean) => ({
4
6
  background: css`
5
7
  padding: 24px;
6
8
 
7
9
  background-color: ${token.colorBgLayout};
8
- background-image: url('/images/screenshot_background.webp');
10
+ background-image: url(${imageUrl('screenshot_background.webp')});
9
11
  background-position: center;
10
12
  background-size: 120% 120%;
11
13
  `,
@@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next';
6
6
  import { Flexbox } from 'react-layout-kit';
7
7
  import { Virtuoso, VirtuosoHandle } from 'react-virtuoso';
8
8
 
9
+ import { imageUrl } from '@/const/url';
9
10
  import { useChatStore } from '@/store/chat';
10
11
  import { topicSelectors } from '@/store/chat/selectors';
11
12
  import { useGlobalStore } from '@/store/global';
@@ -60,7 +61,7 @@ export const Topic = memo(() => {
60
61
  <Flexbox flex={1}>
61
62
  <EmptyCard
62
63
  alt={t('topic.guide.desc')}
63
- cover={`/images/empty_topic_${isDarkMode ? 'dark' : 'light'}.webp`}
64
+ cover={imageUrl(`empty_topic_${isDarkMode ? 'dark' : 'light'}.webp`)}
64
65
  desc={t('topic.guide.desc')}
65
66
  height={120}
66
67
  onVisibleChange={(visible) => {
@@ -4,6 +4,7 @@ import { PropsWithChildren } from 'react';
4
4
  import { isRtlLang } from 'rtl-detect';
5
5
 
6
6
  import Analytics from '@/components/Analytics';
7
+ import { getServerConfig } from '@/config/server';
7
8
  import { DEFAULT_LANG, LOBE_LOCALE_COOKIE } from '@/const/locale';
8
9
  import {
9
10
  LOBE_THEME_APPEARANCE,
@@ -14,6 +15,8 @@ import Layout from '@/layout/GlobalLayout';
14
15
 
15
16
  import StyleRegistry from './StyleRegistry';
16
17
 
18
+ const { ENABLE_OAUTH_SSO } = getServerConfig();
19
+
17
20
  const RootLayout = ({ children }: PropsWithChildren) => {
18
21
  // get default theme config to use with ssr
19
22
  const cookieStore = cookies();
@@ -22,6 +25,7 @@ const RootLayout = ({ children }: PropsWithChildren) => {
22
25
  const primaryColor = cookieStore.get(LOBE_THEME_PRIMARY_COLOR);
23
26
  const lang = cookieStore.get(LOBE_LOCALE_COOKIE);
24
27
  const direction = isRtlLang(lang?.value || DEFAULT_LANG) ? 'rtl' : 'ltr';
28
+
25
29
  return (
26
30
  <html dir={direction} lang={lang?.value || DEFAULT_LANG} suppressHydrationWarning>
27
31
  <body>
@@ -31,6 +35,7 @@ const RootLayout = ({ children }: PropsWithChildren) => {
31
35
  defaultLang={lang?.value}
32
36
  defaultNeutralColor={neutralColor?.value as any}
33
37
  defaultPrimaryColor={primaryColor?.value as any}
38
+ enableOAuthSSO={ENABLE_OAUTH_SSO}
34
39
  >
35
40
  {children}
36
41
  </Layout>
@@ -5,7 +5,7 @@ import Image from 'next/image';
5
5
  import { memo } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
 
8
- import { AGENTS_INDEX_GITHUB } from '@/const/url';
8
+ import { AGENTS_INDEX_GITHUB, imageUrl } from '@/const/url';
9
9
 
10
10
  const Inner = memo(() => {
11
11
  const { t } = useTranslation('market');
@@ -14,7 +14,7 @@ const Inner = memo(() => {
14
14
  <Image
15
15
  alt={'banner'}
16
16
  height={602}
17
- src={'/images/banner_market_modal.webp'}
17
+ src={imageUrl('banner_market_modal.webp')}
18
18
  style={{ height: 'auto', marginBottom: 24, width: '100%' }}
19
19
  width={1602}
20
20
  />
@@ -1,5 +1,6 @@
1
1
  import { Metadata } from 'next';
2
2
 
3
+ import { getClientConfig } from '@/config/client';
3
4
  import { getServerConfig } from '@/config/server';
4
5
 
5
6
  import pkg from '../../package.json';
@@ -8,6 +9,10 @@ const title = 'LobeChat';
8
9
  const { description, homepage } = pkg;
9
10
 
10
11
  const { METADATA_BASE_URL = 'https://chat-preview.lobehub.com/' } = getServerConfig();
12
+ const { BASE_PATH } = getClientConfig();
13
+
14
+ // if there is a base path, then we don't need the manifest
15
+ const noManifest = !!BASE_PATH;
11
16
 
12
17
  const metadata: Metadata = {
13
18
  appleWebApp: {
@@ -22,7 +27,7 @@ const metadata: Metadata = {
22
27
  shortcut:
23
28
  'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/favicon.ico',
24
29
  },
25
- manifest: '/manifest.json',
30
+ manifest: noManifest ? undefined : '/manifest.json',
26
31
  metadataBase: new URL(METADATA_BASE_URL),
27
32
  openGraph: {
28
33
  description: description,
@@ -8,6 +8,7 @@ import { useTranslation } from 'react-i18next';
8
8
 
9
9
  import { FORM_STYLE } from '@/const/layoutTokens';
10
10
  import { DEFAULT_SETTINGS } from '@/const/settings';
11
+ import { imageUrl } from '@/const/url';
11
12
  import AvatarWithUpload from '@/features/AvatarWithUpload';
12
13
  import { localeOptions } from '@/locales/resources';
13
14
  import { useChatStore } from '@/store/chat';
@@ -118,19 +119,19 @@ const Common = memo<SettingsCommonProps>(({ showAccessCodeConfig, showOAuthLogin
118
119
  options={[
119
120
  {
120
121
  icon: Sun,
121
- img: '/images/theme_light.webp',
122
+ img: imageUrl('theme_light.webp'),
122
123
  label: t('settingTheme.themeMode.light'),
123
124
  value: 'light',
124
125
  },
125
126
  {
126
127
  icon: Moon,
127
- img: '/images/theme_dark.webp',
128
+ img: imageUrl('theme_dark.webp'),
128
129
  label: t('settingTheme.themeMode.dark'),
129
130
  value: 'dark',
130
131
  },
131
132
  {
132
133
  icon: Monitor,
133
- img: '/images/theme_auto.webp',
134
+ img: imageUrl('theme_auto.webp'),
134
135
  label: t('settingTheme.themeMode.auto'),
135
136
  value: 'auto',
136
137
  },
@@ -38,6 +38,7 @@ declare global {
38
38
  }
39
39
 
40
40
  export const getClientConfig = () => ({
41
+ BASE_PATH: process.env.NEXT_PUBLIC_BASE_PATH || '',
41
42
  // Vercel Analytics
42
43
  ANALYTICS_VERCEL: process.env.NEXT_PUBLIC_ANALYTICS_VERCEL === '1',
43
44
  VERCEL_DEBUG: process.env.NEXT_PUBLIC_VERCEL_DEBUG === '1',
@@ -52,5 +52,6 @@ export const getAppConfig = () => {
52
52
  AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID || '',
53
53
  AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET || '',
54
54
  AUTH0_ISSUER: process.env.AUTH0_ISSUER || '',
55
+ NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET || '',
55
56
  };
56
57
  };
package/src/const/url.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import urlJoin from 'url-join';
2
2
 
3
+ import { withBasePath } from '@/utils/basePath';
4
+
3
5
  import pkg from '../../package.json';
4
6
  import { INBOX_SESSION_ID } from './session';
5
7
 
@@ -19,3 +21,5 @@ export const AGENTS_INDEX_GITHUB_ISSUE = urlJoin(AGENTS_INDEX_GITHUB, 'issues/ne
19
21
  export const SESSION_CHAT_URL = (id: string = INBOX_SESSION_ID, mobile?: boolean) =>
20
22
  mobile ? `/chat/mobile?session=${id}` : `/chat?session=${id}`;
21
23
  export const MANUAL_UPGRADE_URL = 'https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync';
24
+
25
+ export const imageUrl = (filename: string) => withBasePath(`/images/${filename}`);
@@ -7,6 +7,7 @@ import { memo, useMemo } from 'react';
7
7
  import { useTranslation } from 'react-i18next';
8
8
 
9
9
  import { FORM_STYLE } from '@/const/layoutTokens';
10
+ import { imageUrl } from '@/const/url';
10
11
 
11
12
  import { useStore } from '../store';
12
13
  import ModelSelect from './ModelSelect';
@@ -46,13 +47,13 @@ const AgentConfig = memo(() => {
46
47
  options={[
47
48
  {
48
49
  icon: MessagesSquare,
49
- img: `/images/chatmode_chat_${isDarkMode ? 'dark' : 'light'}.webp`,
50
+ img: imageUrl(`chatmode_chat_${isDarkMode ? 'dark' : 'light'}.webp`),
50
51
  label: t('settingChat.chatStyleType.type.chat'),
51
52
  value: 'chat',
52
53
  },
53
54
  {
54
55
  icon: LayoutList,
55
- img: `/images/chatmode_docs_${isDarkMode ? 'dark' : 'light'}.webp`,
56
+ img: imageUrl(`chatmode_docs_${isDarkMode ? 'dark' : 'light'}.webp`),
56
57
  label: t('settingChat.chatStyleType.type.docs'),
57
58
  value: 'docs',
58
59
  },
@@ -9,7 +9,7 @@ import isEqual from 'fast-deep-equal';
9
9
  import { SWRConfiguration } from 'swr';
10
10
 
11
11
  import { createHeaderWithOpenAI } from '@/services/_header';
12
- import { OPENAI_URLS } from '@/services/_url';
12
+ import { API_ENDPOINTS } from '@/services/_url';
13
13
  import { useGlobalStore } from '@/store/global';
14
14
  import { settingsSelectors } from '@/store/global/selectors';
15
15
  import { useSessionStore } from '@/store/session';
@@ -39,7 +39,7 @@ export const useSTT = (config: STTConfig) => {
39
39
  options = {
40
40
  api: {
41
41
  headers: createHeaderWithOpenAI(),
42
- serviceUrl: OPENAI_URLS.stt,
42
+ serviceUrl: API_ENDPOINTS.stt,
43
43
  },
44
44
  autoStop,
45
45
  options: {
@@ -10,7 +10,7 @@ import {
10
10
  import isEqual from 'fast-deep-equal';
11
11
 
12
12
  import { createHeaderWithOpenAI } from '@/services/_header';
13
- import { OPENAI_URLS, TTS_URL } from '@/services/_url';
13
+ import { API_ENDPOINTS } from '@/services/_url';
14
14
  import { useGlobalStore } from '@/store/global';
15
15
  import { settingsSelectors } from '@/store/global/selectors';
16
16
  import { useSessionStore } from '@/store/session';
@@ -36,7 +36,7 @@ export const useTTS = (content: string, config?: TTSConfig) => {
36
36
  options = {
37
37
  api: {
38
38
  headers: createHeaderWithOpenAI(),
39
- serviceUrl: OPENAI_URLS.tts,
39
+ serviceUrl: API_ENDPOINTS.tts,
40
40
  },
41
41
  options: {
42
42
  model: ttsSettings.openAI.ttsModel,
@@ -64,7 +64,7 @@ export const useTTS = (content: string, config?: TTSConfig) => {
64
64
  useSelectedTTS = useMicrosoftSpeech;
65
65
  options = {
66
66
  api: {
67
- serviceUrl: TTS_URL.microsoft,
67
+ serviceUrl: API_ENDPOINTS.microsoft,
68
68
  },
69
69
  options: {
70
70
  voice: config?.voice || voice,
@@ -8,6 +8,7 @@ import dynamic from 'next/dynamic';
8
8
  import { FC, PropsWithChildren, memo } from 'react';
9
9
 
10
10
  import { getClientConfig } from '@/config/client';
11
+ import { API_ENDPOINTS } from '@/services/_url';
11
12
 
12
13
  import AppTheme, { AppThemeProps } from './AppTheme';
13
14
  import Locale from './Locale';
@@ -45,10 +46,16 @@ const Container = memo<PropsWithChildren>(({ children }) => {
45
46
 
46
47
  interface GlobalLayoutProps extends AppThemeProps {
47
48
  defaultLang?: string;
49
+ enableOAuthSSO?: boolean;
48
50
  }
49
51
 
50
- const GlobalLayout = ({ children, defaultLang, ...theme }: GlobalLayoutProps) => (
51
- <SessionProvider basePath="/api/oauth">
52
+ const GlobalLayout = ({
53
+ children,
54
+ defaultLang,
55
+ enableOAuthSSO = false,
56
+ ...theme
57
+ }: GlobalLayoutProps) => {
58
+ const content = (
52
59
  <AppTheme {...theme}>
53
60
  <Locale defaultLang={defaultLang}>
54
61
  <StoreHydration />
@@ -56,7 +63,13 @@ const GlobalLayout = ({ children, defaultLang, ...theme }: GlobalLayoutProps) =>
56
63
  <DebugUI />
57
64
  </Locale>
58
65
  </AppTheme>
59
- </SessionProvider>
60
- );
66
+ );
67
+
68
+ return enableOAuthSSO ? (
69
+ <SessionProvider basePath={API_ENDPOINTS.oauth}>{content}</SessionProvider>
70
+ ) : (
71
+ content
72
+ );
73
+ };
61
74
 
62
75
  export default GlobalLayout;
package/src/middleware.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // export { auth as middleware } from './app/api/next-auth';
2
2
  import { NextResponse } from 'next/server';
3
3
 
4
- import { auth } from './app/api/oauth/next-auth';
4
+ import { auth } from './app/api/auth/next-auth';
5
5
  import { OAUTH_AUTHORIZED } from './const/auth';
6
6
 
7
7
  export const config = {
@@ -1,21 +1,40 @@
1
- export const URLS = {
1
+ /* eslint-disable sort-keys-fix/sort-keys-fix */
2
+ import { transform } from 'lodash-es';
3
+
4
+ import { withBasePath } from '@/utils/basePath';
5
+
6
+ const mapWithBasePath = <T extends object>(apis: T): T => {
7
+ return transform(apis, (result, value, key) => {
8
+ if (typeof value === 'string') {
9
+ // @ts-ignore
10
+ result[key] = withBasePath(value);
11
+ } else {
12
+ result[key] = value;
13
+ }
14
+ });
15
+ };
16
+
17
+ export const API_ENDPOINTS = mapWithBasePath({
2
18
  config: '/api/config',
3
- market: '/api/market',
4
19
  proxy: '/api/proxy',
5
- };
20
+ oauth: '/api/auth',
21
+
22
+ // agent markets
23
+ market: '/api/market',
6
24
 
7
- export const PLUGINS_URLS = {
25
+ // plugins
8
26
  gateway: '/api/plugin/gateway',
9
- store: '/api/plugin/store',
10
- };
27
+ pluginStore: '/api/plugin/store',
11
28
 
12
- export const OPENAI_URLS = {
29
+ // chat
30
+ chat: (provider: string) => withBasePath(`/api/chat/${provider}`),
31
+
32
+ // image
13
33
  images: '/api/openai/images',
34
+
35
+ // TTS & STT
14
36
  stt: '/api/openai/stt',
15
37
  tts: '/api/openai/tts',
16
- };
17
-
18
- export const TTS_URL = {
19
38
  edge: '/api/tts/edge-speech',
20
39
  microsoft: '/api/tts/microsoft-speech',
21
- };
40
+ });
@@ -16,7 +16,7 @@ import { fetchAIFactory, getMessageError } from '@/utils/fetch';
16
16
 
17
17
  import { createHeaderWithAuth } from './_auth';
18
18
  import { createHeaderWithOpenAI } from './_header';
19
- import { PLUGINS_URLS } from './_url';
19
+ import { API_ENDPOINTS } from './_url';
20
20
 
21
21
  interface FetchOptions {
22
22
  signal?: AbortSignal | undefined;
@@ -81,7 +81,7 @@ class ChatService {
81
81
  provider,
82
82
  });
83
83
 
84
- return fetch(`/api/chat/${provider}`, {
84
+ return fetch(API_ENDPOINTS.chat(provider), {
85
85
  body: JSON.stringify(payload),
86
86
  headers,
87
87
  method: 'POST',
@@ -102,7 +102,7 @@ class ChatService {
102
102
 
103
103
  const gatewayURL = manifest?.gateway;
104
104
 
105
- const res = await fetch(gatewayURL ?? PLUGINS_URLS.gateway, {
105
+ const res = await fetch(gatewayURL ?? API_ENDPOINTS.gateway, {
106
106
  body: JSON.stringify({ ...params, manifest }),
107
107
  // TODO: we can have a better auth way
108
108
  headers: createHeadersWithPluginSettings(settings, createHeaderWithOpenAI()),
@@ -1,9 +1,10 @@
1
1
  import { FileModel } from '@/database/models/file';
2
2
  import { DB_File } from '@/database/schemas/files';
3
- import { URLS } from '@/services/_url';
4
3
  import { FilePreview } from '@/types/files';
5
4
  import compressImage from '@/utils/compressImage';
6
5
 
6
+ import { API_ENDPOINTS } from './_url';
7
+
7
8
  class FileService {
8
9
  private isImage(fileType: string) {
9
10
  const imageRegex = /^image\//;
@@ -43,7 +44,7 @@ class FileService {
43
44
  }
44
45
 
45
46
  async uploadImageByUrl(url: string, file: Pick<DB_File, 'name' | 'metadata'>) {
46
- const res = await fetch(URLS.proxy, { body: url, method: 'POST' });
47
+ const res = await fetch(API_ENDPOINTS.proxy, { body: url, method: 'POST' });
47
48
  const data = await res.arrayBuffer();
48
49
  const fileType = res.headers.get('content-type') || 'image/webp';
49
50
 
@@ -1,6 +1,7 @@
1
- import { URLS } from '@/services/_url';
2
1
  import { GlobalServerConfig } from '@/types/settings';
3
2
 
3
+ import { API_ENDPOINTS } from './_url';
4
+
4
5
  const VERSION_URL = 'https://registry.npmmirror.com/@lobehub/chat';
5
6
 
6
7
  class GlobalService {
@@ -15,7 +16,7 @@ class GlobalService {
15
16
  };
16
17
 
17
18
  getGlobalConfig = async (): Promise<GlobalServerConfig> => {
18
- const res = await fetch(URLS.config);
19
+ const res = await fetch(API_ENDPOINTS.config);
19
20
 
20
21
  return res.json();
21
22
  };
@@ -1,7 +1,8 @@
1
1
  import { createHeaderWithOpenAI } from '@/services/_header';
2
- import { OPENAI_URLS } from '@/services/_url';
3
2
  import { OpenAIImagePayload } from '@/types/openai/image';
4
3
 
4
+ import { API_ENDPOINTS } from './_url';
5
+
5
6
  interface FetchOptions {
6
7
  signal?: AbortSignal | undefined;
7
8
  }
@@ -10,7 +11,7 @@ class ImageGenerationService {
10
11
  async generateImage(params: Omit<OpenAIImagePayload, 'model' | 'n'>, options?: FetchOptions) {
11
12
  const payload: OpenAIImagePayload = { ...params, model: 'dall-e-3', n: 1 };
12
13
 
13
- const res = await fetch(OPENAI_URLS.images, {
14
+ const res = await fetch(API_ENDPOINTS.images, {
14
15
  body: JSON.stringify(payload),
15
16
  headers: createHeaderWithOpenAI({ 'Content-Type': 'application/json' }),
16
17
  method: 'POST',
@@ -1,9 +1,10 @@
1
- import { URLS } from '@/services/_url';
2
1
  import { LobeChatAgentsMarketIndex } from '@/types/market';
3
2
 
3
+ import { API_ENDPOINTS } from './_url';
4
+
4
5
  class MarketService {
5
6
  getAgentList = async (locale: string): Promise<LobeChatAgentsMarketIndex> => {
6
- const res = await fetch(`${URLS.market}?locale=${locale}`);
7
+ const res = await fetch(`${API_ENDPOINTS.market}?locale=${locale}`);
7
8
 
8
9
  return res.json();
9
10
  };
@@ -13,7 +14,7 @@ class MarketService {
13
14
  */
14
15
  getAgentManifest = async (identifier: string, locale: string) => {
15
16
  if (!identifier) return;
16
- const res = await fetch(`${URLS.market}/${identifier}?locale=${locale}`);
17
+ const res = await fetch(`${API_ENDPOINTS.market}/${identifier}?locale=${locale}`);
17
18
 
18
19
  return res.json();
19
20
  };
@@ -5,12 +5,13 @@ import {
5
5
  } from '@lobehub/chat-plugin-sdk';
6
6
 
7
7
  import { PluginModel } from '@/database/models/plugin';
8
- import { PLUGINS_URLS, URLS } from '@/services/_url';
9
8
  import { globalHelpers } from '@/store/global/helpers';
10
9
  import { OpenAIPluginManifest } from '@/types/openai/plugin';
11
10
  import { LobeTool } from '@/types/tool';
12
11
  import { LobeToolCustomPlugin } from '@/types/tool/plugin';
13
12
 
13
+ import { API_ENDPOINTS } from './_url';
14
+
14
15
  export interface InstallPluginParams {
15
16
  identifier: string;
16
17
  manifest: LobeChatPluginManifest;
@@ -21,7 +22,7 @@ class PluginService {
21
22
  // 2. 发送请求
22
23
  let res: Response;
23
24
  try {
24
- res = await (proxy ? fetch(URLS.proxy, { body: url, method: 'POST' }) : fetch(url));
25
+ res = await (proxy ? fetch(API_ENDPOINTS.proxy, { body: url, method: 'POST' }) : fetch(url));
25
26
  } catch {
26
27
  throw new TypeError('fetchError');
27
28
  }
@@ -54,7 +55,7 @@ class PluginService {
54
55
  getPluginList = async (): Promise<LobeChatPluginsMarketIndex> => {
55
56
  const locale = globalHelpers.getCurrentLanguage();
56
57
 
57
- const res = await fetch(`${PLUGINS_URLS.store}?locale=${locale}`);
58
+ const res = await fetch(`${API_ENDPOINTS.pluginStore}?locale=${locale}`);
58
59
 
59
60
  return res.json();
60
61
  };
@@ -112,9 +112,6 @@ export const chatPlugin: StateCreator<
112
112
 
113
113
  invokeStandaloneTypePlugin: async (id, payload) => {
114
114
  const result = await useToolStore.getState().validatePluginSettings(payload.identifier);
115
- console.log('------------------');
116
- console.log(result);
117
- console.log('------------------');
118
115
  if (!result) return;
119
116
 
120
117
  // if the plugin settings is not valid, then set the message with error type
@@ -0,0 +1,3 @@
1
+ import { getClientConfig } from '@/config/client';
2
+
3
+ export const withBasePath = (path: string) => getClientConfig().BASE_PATH + path;
@@ -1,21 +0,0 @@
1
- import NextAuth from 'next-auth';
2
- import Auth0 from 'next-auth/providers/auth0';
3
-
4
- import { getServerConfig } from '@/config/server';
5
-
6
- const { AUTH0_CLIENT_ID, AUTH0_CLIENT_SECRET, AUTH0_ISSUER } = getServerConfig();
7
-
8
- const nextAuth = NextAuth({
9
- providers: [
10
- Auth0({
11
- clientId: AUTH0_CLIENT_ID,
12
- clientSecret: AUTH0_CLIENT_SECRET,
13
- issuer: AUTH0_ISSUER,
14
- }),
15
- ],
16
- });
17
-
18
- export const {
19
- handlers: { GET, POST },
20
- auth,
21
- } = nextAuth;