Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

398
Visualizações
Axios POST request gets CORS error but form submit works fine (Vimeo API)

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.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda