Chainlit / chainlit

Build Conversational AI in minutes ⚡️
https://docs.chainlit.io
Apache License 2.0
7k stars 923 forks source link

Text URL retrieval fails with Google Storage CORS failure. #855

Closed dahifi closed 6 months ago

dahifi commented 6 months ago

When storing Text elements as a message attachment, subsequent retrieval of the attachment URL fails with a CORS error.

To Reproduce Generate a message within CL, or send directly to Literal somehow. This could be within a simple app on_chat_start with data persistence enabled:

    value = "This is a message with a citation[1]. There can be multiple ones in a document[2][3]"
    annotations = [
        cl.Text(name="[1] Annotation Source", url="https://google.com", display="inline"),
        cl.Text(name="[2] Annotation Source", content='content of annotation', display="inline"),
        cl.Text(name="[3] Annotation Source", content='content of annotation', display="inline"),
    ]

    await cl.Message(
        content=value,
        elements=annotations,
    ).send()

Refresh the app and try to select the thread from history. The message will render, but the element will display 'an error occured, while the following is logged in the browser console:

Access to fetch at 'https://storage.googleapis.com/literal-bucket/projects/<REDACTED>' from origin 'https://<ANYWHERE>' has been blocked by CORS policy: 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.

Expected behavior The FE should fetch the attachment from the file and display it.

Screenshots

image
willydouhard commented 6 months ago

Should be fixed!