Open kdta91 opened 1 week ago
Turns out I need to pass in the port 9380 (http://localhost:9380/api/v1) in version 0.13
Reopening this issue as this also happens on production site running on an EC2 instance. The issue is the same as above.
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.
Is there an existing issue for the same bug?
Branch name
main
Commit ID
fa9d76224b5c5c3bc04f5da3e935b0826be95346
Other environment information
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
Additional information
No response