concept browser in category cors

appears as: browser, browsers, The browser, browsers, The browsers, A browser, browser
CORS in Action: Creating and consuming cross-origin APIs

This is an excerpt from Manning's book CORS in Action: Creating and consuming cross-origin APIs.

CORS is simply a way of making HTTP requests from one place to another. This is a trivial thing in other programming languages. But it’s difficult to do in client-side JavaScript, because for years the browser’s same-origin policy has explicitly prevented these types of requests.

Now let’s apply this analogy to the Flickr example from chapter 1. In that example, there is JavaScript code running in the browser, which initiates a request to the Flickr API, as shown in figure 2.3. This request is a cross-origin request because the JavaScript code making the request and the API server receiving the request live on two different websites.

Figure 2.3. Making a request from the browser to the Flickr API

There are a lot of different pieces to making a successful cross-origin request. The client and the server must work together to ensure that the request succeeds. This chapter focuses on the first part of this process: how the client initiates a request to the server . Let’s start by taking a look at which browsers do and don’t support CORS.

Listing 2.7. Creating the correct CORS request object across browsers