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?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
This should be fixed already as per the documentation here:
In order to make requests to the API from other domains, the API implements Cross Origin Resource Sharing (CORS) support.
CORS support is generally used to create AJAX requests outside of the domain that the request originated from. This is necessary to implement projects like control panels utilizing the API. This tells the browser that it can send requests to an outside domain.
However, it’s worth noting that making API requests directly from the client-side JavaScript can expose your API keys to users, which is a security risk. Your API keys can be used to perform any action, including creating and destroying droplets, so you generally want to keep them secret.
A better approach would be to create a server-side component (in Node.js, Python, Ruby, etc.) that makes the API requests to DigitalOcean. This server-side component would keep your API keys secret, and you would control access to the API through your server-side code.
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.