Deploying a droplet from Vue.js app admin panel - blocked by CORS policy


I am trying to launch a new droplet through API the same way as I’ve done from terminal through curl.

curl -X POST “
-H “Authorization: Bearer $TOKEN”
-H “Content-Type: application/json”

This works perfect from the terminal.

What I’m trying to do now is to launch it from just clicking a button in my VueJS Admin panel.

My code is:

   <form class="" method="post" @submit.prevent="DeployNow">


import axios from 'axios'

export default {
  name: 'DeployNow',
  data () {
    return {
      name: '',
      show: false
  methods: {
    async DeployNow () {
      axios.put('', {
        headers: {
          'Content-type': 'application/json'
        params: {
          Param: 'Value'
        'this.names': ',',
        'this.thisregion': 'nyc3',
        'this.size': 's-1vcpu-1gb',
        'this.image': 'ubuntu-16-04-x64',
        'this.Authorization': 'Bearer $TOKEN'

But I’m getting: Access to XMLHttpRequest at ‘’ from origin ‘’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

This is my first time trying to set up a post request to DigitalOcean. I am a bit clueless on how to add my API Key in the code as I’ve tried experimenting with a few options but to no avail.

I’m trying to convert the curl command in vue.js where the request sends the body information like a form or something, then when DigitalOcean receives this information, it would work the same way as the curl command works from terminal.

I’ve spent days trying to find a solution on this so any input and feedback is highly appreciated.

Thank you!

Submit an answer

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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Thanks for the reply!

I’m not using spaces. I’m trying to deploy droplets, so I am a little bit unsure how to apply it in my case.


We have some documentation that may assist on this: