-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accessing flow as API from astra.datastax.com gives CORS error #5386
Comments
To resolve the CORS error when accessing your Langflow API on Astra Datastax, you need to ensure that the CORS settings in your Langflow deployment are correctly configured. Langflow uses app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Allows requests from any origin
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
) If you are still encountering CORS issues, it might be due to specific configurations or restrictions on Astra Datastax. You can try the following:
If the issue persists, it might be helpful to check any logs or debugging tools provided by Astra Datastax to diagnose the problem further. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
I'm getting the same error, and I want to use the API directly from the frontend. Where can I enable CORS on the Langflow platform? I can't find any CORS settings there. Error: |
@dosu Issue is coming when accessing flow as api from live datastax server not local deployment. I dont think i can change any where there. |
To enable CORS settings on the Langflow platform when accessing the API, you need to modify the def create_app():
"""Create the FastAPI app and include the router."""
configure()
socketio_server = socketio.AsyncServer(async_mode="asgi", cors_allowed_origins="*", logger=True)
lifespan = get_lifespan(socketio_server=socketio_server)
app = FastAPI(lifespan=lifespan)
origins = ["*"]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.add_middleware(JavaScriptMIMETypeMiddleware)
# Additional setup code... In this setup, If you are unable to change these settings on a live Datastax server, you might need to check if there are any additional configurations or restrictions imposed by the server environment that could be affecting CORS. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
I created a flow on Astra datastax. it is working fine but when i am trying to use it as api. It giving CORS error. Does it require any special setting there.
Here is the error detail.
Access to fetch at 'https://api.langflow.astra.datastax.com/lf/05174a38-787c-439e-ad84-28445ceb70ad/api/v1/run/feaab329-bd0c-4a5e-a1c5-22eb9e87451d?stream=false' from origin 'null' 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
The text was updated successfully, but these errors were encountered: