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
45.05k stars 10.16k forks source link

[Bug] Unable to Upload File #3813

Open josenxx opened 2 months ago

josenxx commented 2 months ago

📦 Environment

Vercel

📌 Version

v1.15.14

💻 Operating System

macOS

🌐 Browser

Chrome

🐛 Bug Description

I try to upload files to the knowledge base. Hoever, it just stuck in the uploading forever.

2024-09-08 01 45 54

I followed the instruction https://lobehub.com/docs/self-hosting/start and checked everything many times. It is likely that there is a problem in my setting, However, the change is low. I also read other similar issues like https://github.com/lobehub/lobe-chat/issues/3778 However I do not get any error message, so the behavior is different.

I can only show the log of vercel. After uploading file, it just stuck there and I cannot see another change.

2024-09-08 01 46 09

It is clear that no files is uploaded.

2024-09-08 01 48 00

There are my setting is cloudflare r2

2024-09-08 01 59 07 2024-09-08 01 59 20 2024-09-08 01 59 37

📷 Recurrence Steps

No response

🚦 Expected Behavior

No response

📝 Additional Information

No response

lobehubbot commented 2 months ago

👀 @josenxx

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 months ago

Hey @josenxx, I'm here to help you with your bug report. Let's work together to solve this issue!

I found a similar unsolved discussion and a closed issue that might be relevant to your problem:

  1. Unsolved Discussion: [Bug] 上传文件报错,已经对接cloudflareR2存储 [1].
  2. Closed Issue: [Bug] [2]. The suggested solution was to add the website domain name to CloudFlare's CORS policy.

Based on your description and the provided images, it seems like the issue might be related to the S3_ENDPOINT environment variable. Ensure that the path in the S3_ENDPOINT link does not include the bucket name. For example, if your current S3_ENDPOINT is:

S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com/lobechat

It should be:

S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com

Make sure to update this in your Vercel environment variables.

Additionally, ensure that you have configured the necessary S3 access keys and CORS settings as described in the Cloudflare R2 setup documentation. Here is a summary of the required environment variables:

# S3 Keys
S3_ACCESS_KEY_ID=your_access_key_id
S3_SECRET_ACCESS_KEY=your_secret_access_key

# Bucket Name
S3_BUCKET=lobechat
# Bucket Request Endpoint
S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
# Public Access Domain for the Bucket
S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com

Ensure that the CORS configuration allows your Vercel domain:

[
  {
    "AllowedOrigins": ["https://your-project.vercel.app"],
    "AllowedMethods": ["GET", "PUT", "HEAD", "POST", "DELETE"],
    "AllowedHeaders": ["*"]
  }
]

By following these steps, you should be able to resolve the file upload issue on Vercel using Cloudflare R2 [3][4][5][6].

To continue talking to Dosu, mention @dosu.

josenxx commented 2 months ago

@dosu how to set Public Access Domain for the Bucket

dosubot[bot] commented 2 months ago

To set the Public Access Domain for the Bucket in Cloudflare R2, you need to configure the S3_PUBLIC_DOMAIN environment variable with the appropriate URL. Here is the relevant information:

# Public Access Domain for the Bucket
S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com

Make sure to replace https://s3-for-lobechat.your-domain.com with your actual domain [1][2].

To continue talking to Dosu, mention @dosu.