Knowledge Base

The leading provider of version control solutions and TWAIN SDKs

Error "XMLHttpRequest cannot load ***. No 'Access-Control-Allow-Origin' header is present on the requested resource."

Error:

XMLHttpRequest cannot load ***. No 'Access-Control-Allow-Origin' header is present on the requested resource.

Causes:

You are accessing web resources on different domains or ports.

For example, if you are on the website http://demo1.dynamsoft.com and are trying to use readURL method to read barcode from the image (https://www.dynamsoft.com/demo/DWT/Images/code-39.png) which is on a different domain, you will get the above error in the console.

Resolution:

Please update your server configration file as per your environment. If you are using IIS, here is the web config scripts for your reference.

<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="OPTIONS,POST,GET,PUT" />
<add name="Access-Control-Allow-Headers" value="x-requested-with" />
<add name="Access-Control-Allow-Credentials" value="true" />
</customHeaders>
</httpProtocol>
</system.webServer>

If you are using Windows Authentication, you may need to change the default setting of "withCredentials" in the dynamsoft.webtwain.initiate.js file. To do that, please open the JS file and search for "withCredentials:false". Please change the value to "withCredentials:true".

Notes:
  1. After updating the server configuration file, you'll need to restart the server (e.g. IIS).
  2. You might need to clear browsing history in the browser on the client side.





Article Details

Last Updated
26th of April, 2017

Would you like to...

Print this page Print this page

Email this page Email this page

Post a comment Post a comment

Subscribe me

Add to favorites Add to favorites

Remove Highlighting Remove Highlighting

Edit this Article

Quick Edit

Export to PDF

User Opinions (0 votes)

No users have voted.

How would you rate this answer?



Thank you for rating this answer.

Related Articles

No related articles were found.

Attachments

No attachments were found.

Continue