infiniflow / ragflow

RAGFlow is an open-source RAG (Retrieval-Augmented Generation) engine based on deep document understanding.
https://ragflow.io
Apache License 2.0
22.88k stars 2.24k forks source link

[Bug]: Upgraded to version 0.13 from 0.12. New API endpoints doesn't work. #3176

Open kdta91 opened 1 week ago

kdta91 commented 1 week ago

Is there an existing issue for the same bug?

Branch name

main

Commit ID

fa9d76224b5c5c3bc04f5da3e935b0826be95346

Other environment information

PopOS 22.04
AMD Ryzen 5 3600
AMD Radeon RX 5600 XT
16GB RAM

Actual behavior

I have a fully working version 0.12 and have upgraded to the latest version 0.13 and have updated the endpoints to the latest one following the HTTP API Reference so the base URL would now be http://localhost/api/v1 (previously: http://localhost/v1/api) and now I am getting a CORS error from my chatbot interface at http://localhost:3000. Weirdly, when using the old endpoint from 0.12 it works as expected.

The error in the log is as follows: Access to fetch at 'http://localhost/api/v1/chats/a8be5c10879411ef8f4b6dd911818357/sessions' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Here is the POST request to create a new session: const response = await fetch( ${config("ragflow_url")}/chats/${chatId}/sessions, { method: "POST", headers, body: JSON.stringify({ name }), } );

and the POST request to start a new conversation: const res = await fetch( ${config("ragflow_url")}/chats/${chatId}/completions, { headers: headers, method: "POST", body: JSON.stringify({ question: messages[1]["content"], stream: true, session_id, }), } );

Variables: chatId = process.env.NEXT_PUBLIC_RAGFLOW_CHATID config("ragflow_url") = http://localhost/api/v1

Expected behavior

It should return their respective response and not a CORS error.

Steps to reproduce

From version 0.12 upgrade to the latest version 0.13.

Update the old API endpoint to the latest endpoint. (http://localhost/v1/api -> http://localhost/api/v1

Additional information

No response

kdta91 commented 1 week ago

Turns out I need to pass in the port 9380 (http://localhost:9380/api/v1) in version 0.13

kdta91 commented 3 days ago

Reopening this issue as this also happens on production site running on an EC2 instance. The issue is the same as above.

  1. Updated from version 0.12 to the latest version 0.13.
  2. Update the old API endpoint to the latest endpoint: https://domain/v1/api -> https://domain/api/v1

Getting 404 error when accessing https://domain/api/v1 but getting a response from old ULR https://domain/v1/api.

When accessed from a static web app hosted on an S3 bucket, error is: Access to fetch at 'https://domain/api/v1/chats/chat_id/sessions' from origin 'https://s3-domain/index.html' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.