Mintplex-Labs / anything-llm

The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, and more.
https://anythingllm.com
MIT License
27.48k stars 2.77k forks source link

'400 Bad Request' occurs once uploading a document when running in production without docker #2527

Closed fengnex closed 4 weeks ago

fengnex commented 4 weeks ago

Reproducing steps:

  1. Set up the environment according to https://github.com/Mintplex-Labs/anything-llm/blob/master/BARE_METAL.md
  2. Add console.log(res); at the line of 65 in server/utils/collectorApi/index.js
  3. Execute cd server && node index.js from the home directory and then execute cd collector && node index.js from the same dir in another terminal window
  4. Try to upload a document and then the UI would be: anthingllm-400-1
  5. Check the server's console then the following response can be found: Response { status: 400, statusText: 'Bad Request', headers: Headers { 'x-powered-by': 'Express', vary: 'Origin', 'content-type': 'application/json; charset=utf-8', 'content-length': '43', etag: 'W/"2b-+vivW5V/CWdmo6x7+lEhhCy5OUo"', date: 'Thu, 24 Oct 2024 04:30:42 GMT', connection: 'keep-alive', 'keep-alive': 'timeout=5' }, body: ReadableStream { locked: false, state: 'readable', supportsBYOB: true }, bodyUsed: false, ok: false, redirected: false, type: 'basic', url: 'http://0.0.0.0:8888/process' } [CollectorApi] Response could not be completed

By the way, the above function runs smoothly and correctly when the server, the collector and the frontend run in development mode.

Can anyone be so kind as to explain relevant problems or root causes, and give some ideas on how to solve it? Thanks a lot in advance!

fengnex commented 4 weeks ago

@timothycarambat Could you please look at this problem and provide some ideas? Thanks

timothycarambat commented 4 weeks ago

https://github.com/Mintplex-Labs/anything-llm/blob/master/BARE_METAL.md

[!WARNING] This method of deployment is not supported by the core-team and is to be used as a reference for your deployment. You are fully responsible for securing your deployment and data in this mode. Any issues experienced from bare-metal or non-containerized deployments will be not answered or supported.

I will hopefully get to this, but it is nearly impossible to support people like this - especially over Github. This is 100% a configuration issue, I just cant be sure of what.

In general, people just fail to set the .env for the server in server/.env correctly almost 100% of the time.

SERVER_PORT=3001
STORAGE_DIR="/absolute/path/to/anything-llm/server/storage" # absolute filesystem path with no trailing slash
DATABASE_URL="file:/absolute/path/to/anything-llm/server/storage/anythingllm.db"

SInce the app loads and you have a workspace, your DatabaseURL is correct (likey using the default), but your storage directory may be wrong. Collector can be checked in this mode by GET http://localhost:8888/accepts and should get a JSON array back.