DEV Community

Ramiro for Auth0

Posted on • Updated on • Originally published at


CORS Tutorial: A Guide to Cross-Origin Resource Sharing

In this article, we'll take a look at CORS, the circumstances under which it is needed, the benefits it provides, and how to configure a Node + Express application to support CORS. If you wish, you can grab the accompanying source code from GitHub!

Cross-Origin Resource Sharing (CORS) is a protocol that enables scripts running on a browser client to interact with resources from a different origin. This is useful because, thanks to the same-origin policy followed by XMLHttpRequest and fetch, JavaScript can only make calls to URLs that live on the same origin as the location where the script is running. For example, if a JavaScript app wishes to make an AJAX call to an API running on a different domain, it would be blocked from doing so thanks to the same-origin policy.

But why is this necessary, and how does it work?

Continue Reading 🛠

Top comments (1)

michaelrice profile image
Michael Rice

CORS gives me the willies. Or is it just me?