fetchai / uAgents

A fast and lightweight framework for creating decentralized agents with ease.
Apache License 2.0
978 stars 233 forks source link

CORS support for REST endpoints [Calhacks] #563

Open divikshrivastava opened 4 days ago

divikshrivastava commented 4 days ago

Prerequisites

Feature

CORS is a concept for whitelisting the use of APIs from cross-origin resources, and is generally facilitated by flask-cors or CORS middleware in Python and Node js respectively. However, in the agentic deployment of Fetch AI, there is no direct support of this option and requires to be an essential parameter when creating an Agent.

Additional Information (Optional)

No response

divikshrivastava commented 4 days ago

Also I would love to take a stab at it myself @lrahmani @jrriehl

Archento commented 3 days ago

Thank you for the feedback!

The current implementation works on the assumption that the used uvicorn (and in respect starlette) server is capable of accepting and properly implementing the necessary CORS handshake. During testing this seemed to have worked for certain domains but it was no reliable or satisfactory solution so we are aware of the need to update this in the future. As you can see in the reference code for the asgi server we do already try to set the necessary headers during initialisation of the server so the next step if that doesn't work as expected is to actually add this middleware logic ourselves.

We are currently working on a major update to the server and it makes sense to add these acknowledgment messages from the agent there but feel free to take a stab at it! And if it possible we'll take this over to the new server :)