OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

Fix Cors issue with files endpoints

Open dred0n opened this issue 1 year ago • 2 comments

Issue:

The following endpoint used json.dumps as a return for the endpoints

/refresh-files /select-file

This conflicts with FastAPI's ability to assign the proper response headers causing CORS issues.

Also, the client side handler code was adjusted to work with the FastAPI rendered JSON response.

dred0n avatar Apr 08 '24 03:04 dred0n

This seems like the right fix to me! CORS is a weird tripping point though, are you sure it's CORS and not the lack of content-type in the response?

rbren avatar Apr 08 '24 15:04 rbren

This seems like the right fix to me! CORS is a weird tripping point though, are you sure it's CORS and not the lack of content-type in the response?

Yeah, I'm sure.

For this particular issue json.dumps conflicts with FASTAPI sending the CORS response headers. From the client-side it produces the typical CORS error where the response is blocked. The Content-Type as application/json is present in the response header.

dred0n avatar Apr 08 '24 15:04 dred0n