No Access-Control-Allow-Origin header is present on the requested resource 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.

Published on Jun 15, 2022

Tags: AJAX | JavaScript | cors

Related Posts

Did you enjoy this article? If you did here are some more articles that I thought you will enjoy as they are very similar to the article that you just finished reading.


Learn how to code in HTML, CSS, JavaScript, Python, Ruby, PHP, Java, C#, SQL, and more.

No matter the programming language you're looking to learn, I've hopefully compiled an incredible set of tutorials for you to learn; whether you are beginner or an expert, there is something for everyone to learn. Each topic I go in-depth and provide many examples throughout. I can't wait for you to dig in and improve your skillset with any of the tutorials below.