Search⌘ K

Activation of CORS

Understand the Cross-Origin Resource Sharing (CORS) mechanism and learn how to enable and configure it in a Rails API. This lesson helps you avoid common CORS-related errors when making requests from different domains and shows you how to modify the Rails cors.rb initializer for secure and controlled access.

We'll cover the following...

In this lesson, we’ll discuss one final problem often encountered when working with an API.

When we first request an external site (via an AJAX request, for example), we will encounter an error of this kind:

“Failed to load https://example.com/ No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin “ ...