I am trying out the upload videos API from Vimeo: https://developer.vimeo.com/api/upload/videos#form-approach
So I got the form from the first step, as shown here: picture of HTML form I got from upload.form field in the response
And I wanted to upload the video without users having to submit the form, so instead of redirecting the user to the form, I sent a POST request manually to the API endpoint given:
// resJson.upload.upload_link is the same link as the form action attribute
axios.post(resJson.upload.upload_link, formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
})
But I got a CORS error:
Access to XMLHttpRequest at {link} from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
However, the code works fine if I just submit using the form. May I ask what is the difference of submitting a form and doing a POST request to the same link? Is there any way that I can submit the form automatically without having users do anything? The form data is already on the client side browser so there is no need for the user to browse and upload the file manually.