Operation API: CORS

How do we enable cors for our accounts? Is it possible to upload files directly from Javascript? Access to XMLHttpRequest at 'https://api.videoindexer.ai/trial/Accounts/{accountId}/Videos?name={videoName}&accessToken={token}&privacy=Private&callbackUrl={callbackUrl}&sendSuccessEmail=false' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.



    +1. Is this an issue introduced recently ? My React App doesnt work but Postman works.
    Posted by Hidden Thu, 27 Jun 2019 08:33:08 GMT
    Hey! There was no change recently. You can even try the request from your console and see it works. Also, you can try out our app and see that when uploading a video the response returns Access-Control-Allow-Origin: *. Please make sure you wrote your request correct and update us. Here is a code snippet in JS that we also have in our api page - $(function() { $.ajax({ url: "https://api.videoindexer.ai/{region}/Accounts/{accountId}/Videos?name={videoName}&accessToken={accessToken}&privacy=Private&videoUrl={yourURL}", beforeSend: function(xhrObj){ // Request headers xhrObj.setRequestHeader("Content-Type","multipart/form-data"); }, type: "POST", // Request body data: "{body}", }) .done(function(data) { alert("success"); }) .fail(function() { alert("error"); }); }); Hope that helps Nofar
    Posted by Hidden Thu, 27 Jun 2019 09:57:26 GMT
    I loaded up the Application you provide and looked at the request for video upload. It is using a different address than api.videoindexer.ai. Your documentation is also using this api.videoindexer.ai but that address does not return Access-Control-Allow-Origin: *. This is the address that I ended up using and have been getting successful results back from: https://www.videoindexer.ai/api/v2/accounts/{account}/videos?name={name}&accessToken={key}&privacy=Private&callbackUrl={callbackUrl}&sendSuccessEmail=false Attached is a file using Postman to show the response coming back from api.videoindexer.ai. Thanks, Jason
    Posted by Hidden Thu, 27 Jun 2019 19:14:00 GMT
    And did you added an origin header? I tried it also at a simple codepen project and it worked. Here is my example - https://codepen.io/nofareadn/pen/KjQmJR?editors=1111 (You will see at the first an error because I haven't added any accessToken)
    Posted by Hidden Sun, 30 Jun 2019 10:25:47 GMT
    Thanks for the help. Our application was sending in an extra header for x-zumo-auth and it was causing the pre-flight error. After removing that header, the upload to api.videoindexer.ai works as expected. Thanks again for your help, Jason
    Posted by Hidden Mon, 01 Jul 2019 20:46:43 GMT

You're not signed in. Please sign-in to report an issue or post a comment.