Unable to query droplets API - CORS error

August 19, 2019 221 views
DigitalOcean API

I am trying to query the droplets on my account (https://api.digitalocean.com/v2/droplets) - I am using jquery with crossDomain set to true. This call used to work correctly, but is now returning a CORS error. I am able to use the same jquery code to call the account API with no issues, so I know that my credentials and headers are being set correctly…

Has the access to the droplets API changed?

3 comments
  • Here is a bit more info. The following fails:

                $.ajax({
                    type: "GET",
                    url: "https://api.digitalocean.com/v2/droplets",
                    crossDomain: true,
                    contentType: 'application/json',
                    beforeSend: function (xhr) {
                        xhr.setRequestHeader ("Authorization", "Bearer <MY TOKEN>");
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        console.log(textStatus)
                    },
                    success: function (data) {
                        console.log("Yay!")
                    }
                });
    

    But running in curl succeeds:

    curl -H "Origin: http://localhost:3000" -H "Authorization: Bearer <MY TOKEN>" -H "Content-Type: application/json" -X GET "https://api.digitalocean.com/v2/droplets"
    
    edited by MattIPv4
  • Hey @sconrad, we are looking into this internally and will share an update with the Community here once we have one :)

  • Any updates on this? Thanks!

Be the first one to answer this question.