Search code examples
reactjscorscross-domain

Appwrite + React :Cross-Origin Request Blocked


Am trying pull data from appwrite but am getting CORs error. Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://cloud.appwrite.io.v1/databases/{databaseId}/collections/{collectionId}/documents. (Reason: CORS request did not succeed). Status code: (null)

how do i resolve this in react or appwrite dashboard


Solution

  • CORS errors when working with Appwrite can be caused by a number of reasons. Here's a list of things that you can try, and see if any of them works:

    • Make sure you have added your client-side app as a platform in the appwrite dashboard.
    • Make sure that the Hostname is set correctly in the platform. If your client-side app is hosted on https://subdomain.example.com, the hostname you should use is subdomain.example.com.
    • Make sure you're initializing your client with the correct Project ID, and endpoint: reference

    Make sure you try all the suggestions, and let me know if you face any issues :)