JavaScript XHR request fails due to CORS

  • Last Post 13 December 2016
opodopolopolous posted this 29 March 2016

Hi, We're attempting to implement the OCR SDK using the browser, however we've run into an issue with CORS (Cross-Origin Resource Sharing) Since we are posting to a different domain than our web service is hosted on, JavaScript sends a preflight OPTIONS request before the POST. (There is no way I can change/bypass this) When the OPTIONS request is sent however, your SDK returns a 404, therefore the XHR request fails.

I believe there to be two solutions to this problem. Either you need to support the OPTIONS verb, or you could accept authorization via the request bode (ie in the POST fields) instead of as an auth header (as this will not trigger CORS to send an OPTIONS request)

EDIT: I was able to work around the OPTIONS request, however the response from the post does not include the "Access-Control-Allow-Origin" header, therefore the response is still rejected.

Please advise ASAP.

Regards, Leo

  • Liked by
  • awynham
Order By: Standard | Newest | Votes
Oksana S. posted this 29 March 2016

I have consulted with our developers, they recommend you to keep the authorization data in the JavaScript itself and put them to the request right from there.

opodopolopolous posted this 30 March 2016

I'm happy to put the authorization data in the header, however as I said, when I do this, a preflight OPTIONS request is sent before the POST (in accordance with web standards) which your API does not handle. Can you please consult with your developers on the matter, as your API (rather, your web server configuration) needs to be updated.

Oksana S. posted this 04 April 2016

I have consulted with the developers once again concerning your usage scenario. Unfortunately, we are not going to support such kind of requests so far.

Also I can see from our database that you have already successfully processed several tasks for last few days. Kindly specify if you have managed to work around the issue.

awynham posted this 13 December 2016

I have the need for CORS support also as I am invoking from a web page. Right now I am getting around it by proxying requests to my server first. This seems to work fine for the API (i.e. start job, get status) but the download of the results from still won't work.

Oksana S. posted this 13 December 2016

Hi! Please send us the logs from any HTTP debugger (for example, Fiddler or its analogue) to, so that we can consult the developers. Thanks!