Question

Unable to query droplets API - CORS error

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?

Subscribe
Share

Any updates on this? Thanks!

Hey @sconrad, we are looking into this internally and will share an update with the Community here once we have one :)

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"

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!