No Access-Control-Allow-Origin header is present on the requested resource


Are you confused why you are getting this error? This error is caused when you are trying to perform an AJAX call from one site to a different site. Because Javascript is a client-side application it requires additional security to help protect the users from malicious code, e.g. calling a different site without the user knowing.

To solve this problem you need to install CORS on the website you’re making the call TO not FROM. You then configure CORS to allow the site you are calling FROM to be a valid URL. I’ve provided a detailed explanation of Solving No Access-Control-Allow-Origin with Node js and Express

What is CORS?

The best way to describe this is a quote from Wikipedia: “Cross-origin resource sharing is a mechanism that allows restricted resources on a web page to be requested from another domain outside the domain from which the first resource was served. A web page may freely embed cross-origin images, stylesheets, scripts, iframes, and videos.”

StackOverFlow has an incredible list of questions on how to enable CORS basically for any type of server-side code and even browser.

About the author

By Jamie

My Books