Skip to main content

CORS Error when fetching folders in browser

Comments

1 comment

  • Stephen Doyle

    Hi Rotimi,

    As a general issue, making CORS requests from localhost will not work in many cases because web services often expect that requests are being made from a fully qualified domain name.  

    For this specific example, it's not supported or recommend to call our Admin API methods from frontend code, and our Node SDK is not intended for use in frontend code either and will likely be missing dependencies that are expected to be present in a Node server but won't be present in frontend code.

    It's not possible to call Admin API methods safely from frontend code because they require authentication using your account's API Secret, and doing so leaves your account vulnerable and allows your users to make arbitrary API calls to the account.

    It's also difficult to call Upload API methods from frontend code unless you have a server-side endpoint providing the necessary signature for Upload API calls (and in that case, it's easier to call the API from the server-side and pass the results to your frontend)

    For this example, I recommend that you keep your own database of assets on the server side and use that to populate your frontend, or add a mechanism where your frontend code asks your server to make the API call and then pass the result to your frontend

    Regards,

    Stephen

    0

Post is closed for comments.