lobehub / lobe-chat

🤯 Lobe Chat - an open-source, modern-design AI chat framework. Supports Multi AI Providers( OpenAI / Claude 3 / Gemini / Ollama / Azure / DeepSeek), Knowledge Base (file upload / knowledge management / RAG ), Multi-Modals (Vision/TTS) and plugin system. One-click FREE deployment of your private ChatGPT/ Claude application.
https://chat-preview.lobehub.com
Other
44.9k stars 10.11k forks source link

[Bug] 「部署问题」Casdoor 配置与 NextAuth 认证错误 #4760

Open Shukino20001015 opened 2 days ago

Shukino20001015 commented 2 days ago

📦 Environment

Docker

📌 Version

1.0

💻 Operating System

Ubuntu

🌐 Browser

Chrome

🐛 Bug Description

你好,在按照官方文档 https://lobehub.com/zh/docs/self-hosting/server-database/docker-compose 进行部署时遇到了问题。

当前进度:

已完成"发布到生产(IP 模式)"的配置步骤 Casdoor 通过 MinIO buckets 上传资源成功 Lobe UI 界面可以访问 遇到的问题:

登录时显示页面存在问题 后台日志显示 NextAuth 错误: log

‘’‘ [Database] Start to migration... ✅ database migration pass.

▲ Next.js 14.2.8

观察到的现象: 在 Casdoor 上:

每次重启服务后,MinIO 服务商的配置会重置 应用的转发 API 路径配置也需要重新设置 疑问:

Casdoor 配置无法持久化是否是导致认证失败的原因? 如何解决这些配置在重启后丢失的问题? 请问有什么解决方案?感谢帮助!

📷 Recurrence Steps

根据文档做的步骤,没有啥变动,顶多加了几个llm api 环境变量

🚦 Expected Behavior

我的服务能够在局域网/公网中正常使用,即可以用户注册使用服务

📝 Additional Information

123

lobehubbot commented 2 days ago

👀 @Shukino20001015

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. Please make sure you have given us as much context as possible.\ 非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

dosubot[bot] commented 2 days ago

@Shukino20001015 你好!我是Dosu,一个可以帮助解决错误、回答问题并成为贡献者的机器人。我会在这里帮助你等待人类维护者的过程中。

I found some similar discussions that might help with your issue:

  1. [Bug] Docker Compose部署无法使用: This discussion was resolved by addressing a firewall issue. The user initially couldn't log in due to a firewall problem, which was resolved by opening the necessary port [1].

  2. LobeChat 因授权问题无法连接至MinIO服务器: This discussion highlights the importance of having a login system configured, as the lack of it can lead to authorization failures [2].

  3. [Bug] next-auth fetch failed with third auth provider: This issue was resolved by using a PROXY_URL, which might be relevant if you're encountering fetch errors with NextAuth [3].

Regarding your specific issue with Casdoor configuration not persisting across service restarts, I couldn't find a direct solution in the available data. However, ensuring that your Docker volumes are correctly set up to persist data might help. This typically involves checking your Docker Compose configuration to ensure that volumes are mapped correctly for Casdoor's data storage.

For the NextAuth configuration error, make sure all required environment variables are correctly set. You can refer to the specific environment variables needed for NextAuth in the Lobe Chat setup [4][5][6].

If the Casdoor configuration reset is causing the authentication failure, ensuring persistent storage for Casdoor's configuration might resolve the issue. You might need to check if the Casdoor service is writing its configuration to a persistent volume.

To continue talking to Dosu, mention @dosu.

Shukino20001015 commented 2 days ago

这是casdoor重启前: image

这是重启后: image

配置似乎没有持久化,我想知道是不是这个原因导致我的用户注册失败的?

lobehubbot commented 2 days ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


This is before casdoor restarts: image

This is after reboot: image

The configuration does not seem to be persisted. I would like to know if this is the reason why my user registration failed?

SpeedupMaster commented 2 days ago

用啥部署的?配置应该是有持久化储存的

lobehubbot commented 2 days ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


What was deployed using? Configuration should be persistently stored

Shukino20001015 commented 2 days ago

用啥部署的?配置应该是有持久化储存的

image

image

现在我修改了外部的init_data.json,现在重启是可以看到配置了,提供商上传资源正常,但是lobe chat 界面登录还是存在问题,最终会得到”http://192.168.2.6:3210/api/auth/error?error=Configuration“这个结果。不理解为啥还是不能实现本地用户登录&注册

SpeedupMaster commented 2 days ago

用啥部署的?配置应该是有持久化储存的

image

image

现在我修改了外部的init_data.json,现在重启是可以看到配置了,提供商上传资源正常,但是lobe chat 界面登录还是存在问题,最终会得到”http://192.168.2.6:3210/api/auth/error?error=Configuration“这个结果。不理解为啥还是不能实现本地用户登录&注册?

你需要修改下载下来的 docker-compose.yml 文件,执行一次全文替换,将 localhost 替换为 your_server_ip。 这个有替换吗?

Shukino20001015 commented 2 days ago

用啥部署的?配置应该是有持久化储存的

image image 现在我修改了外部的init_data.json,现在重启是可以看到配置了,提供商上传资源正常,但是lobe chat 界面登录还是存在问题,最终会得到”http://192.168.2.6:3210/api/auth/error?error=Configuration“这个结果。不理解为啥还是不能实现本地用户登录&注册?

你需要修改下载下来的 docker-compose.yml 文件,执行一次全文替换,将 localhost 替换为 your_server_ip。 这个有替换吗?

"sed -i 's/localhost/192.168.2.6/g' docker-compose.yml"替换了

SpeedupMaster commented 2 days ago

用啥部署的?配置应该是有持久化储存的

image image 现在我修改了外部的init_data.json,现在重启是可以看到配置了,提供商上传资源正常,但是lobe chat 界面登录还是存在问题,最终会得到”http://192.168.2.6:3210/api/auth/error?error=Configuration“这个结果。不理解为啥还是不能实现本地用户登录&注册?

你需要修改下载下来的 docker-compose.yml 文件,执行一次全文替换,将 localhost 替换为 your_server_ip。 这个有替换吗?

"sed -i 's/localhost/192.168.2.6/g' docker-compose.yml"替换了

那配置应该没问题的啊,可以检查下docker-compose.yml文件,确认下是否成功替换了

Shukino20001015 commented 2 days ago

用啥部署的?配置应该是有持久化储存的

image image 现在我修改了外部的init_data.json,现在重启是可以看到配置了,提供商上传资源正常,但是lobe chat 界面登录还是存在问题,最终会得到”http://192.168.2.6:3210/api/auth/error?error=Configuration“这个结果。不理解为啥还是不能实现本地用户登录&注册?

你需要修改下载下来的 docker-compose.yml 文件,执行一次全文替换,将 localhost 替换为 your_server_ip。 这个有替换吗?

"sed -i 's/localhost/192.168.2.6/g' docker-compose.yml"替换了

那配置应该没问题的啊,可以检查下docker-compose.yml文件,确认下是否成功替换了

是啊,lobechat页面可以显示出来,但是登录注册跳转到casdoor失败,然后是log里有“[auth][error] TypeError: fetch failed at node:internal/deps/undici/undici:13185:13 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async iB (/app/.next/server/chunks/39652.js:368:46804) at async iG (/app/.next/server/chunks/39652.js:368:49678) at async i0 (/app/.next/server/chunks/39652.js:368:52320) at async i2 (/app/.next/server/chunks/39652.js:368:56476) at async /app/nodemodules/.pnpm/next@14.2.8@babel+core@7.23.6_@opentelemetry+api@1.9.0_react-dom@18.3.1_react@18.3.1react@18.3.1/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:36932 at async eC.execute (/app/nodemodules/.pnpm/next@14.2.8@babel+core@7.23.6_@opentelemetry+api@1.9.0_react-dom@18.3.1_react@18.3.1react@18.3.1/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:27548) at async eC.handle (/app/nodemodules/.pnpm/next@14.2.8@babel+core@7.23.6_@opentelemetry+api@1.9.0_react-dom@18.3.1_react@18.3.1react@18.3.1/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:38186) at async doRender (/app/nodemodules/.pnpm/next@14.2.8@babel+core@7.23.6_@opentelemetry+api@1.9.0_react-dom@18.3.1_react@18.3.1react@18.3.1/node_modules/next/dist/server/base-server.js:1359:42) [NextAuth] Error: { cause: 'Configuration', message: 'Wrong configuration, make sure you have the correct environment variables set. Visit https://lobehub.com/docs/self-hosting/advanced/authentication for more details.', name: 'NextAuth Error' } [NextAuth] Error: { cause: 'Configuration', message: 'Wrong configuration, make sure you have the correct environment variables set. Visit https://lobehub.com/docs/self-hosting/advanced/authentication for more details.', name: 'NextAuth Error' } [auth][error] TypeError: fetch failed”这种字样,我不大清楚该如何解决了。。

arvinxx commented 18 hours ago

@Shukino20001015

TypeError: fetch failed 说明是请求失败,检查下连通性是否正常。确认下没有被墙之类的

lobehubbot commented 18 hours ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


TypeError: fetch failed indicates that the request failed. Check whether the connectivity is normal. Make sure there is no wall or anything like that