
H 'Origin: This request basically says "I would like to make a GET request with the Content -Type and Accept headers from - is that possible?". H 'Access-Control-Request-Headers: Content-Type, Accept' \ H 'Access-Control-Request-Method: GET' \ Origin: The usual origin header that contains the script's current originĪn example of such a request might look like this: # Request curl -i -X OPTIONS localhost:3001/api/ping \.Access -Control -Request -Headers: An indication of the custom headers that will be sent with the request.Access -Control -Request -Method: The intended method of the request (e.g., GET or POST).The preflight request sets the mode as OPTIONS and sets a couple of headers to describe the actual request that is to follow: If the result of the OPTIONS call dictates that the request cannot be made, the actual request to the server will not be executed. This call is used to determine the exact CORS capabilities of the server, which is in turn used to determine whether or not the intended CORS protocol is understood. If a request does not meet the criteria for a simple request, the browser will instead make an automatic preflight request using the OPTIONS method. The request is allowed to continue as normal if it meets these criteria, and the Access -Control -Allow -Origin header is checked when the response is returned. No ReadableStream object is used in the request.No event listeners are registered on any XMLHttpRequestUpload object.

When using the Content -Type header, only the following values are allowed: application /x -www -form -urlencoded, multipart /form -data, or text /plain.One of these methods is used: GET, POST, or HEAD.The browser deems the request to be a "simple" request when the request itself meets a certain set of requirements: Let's have a look at what that means in more detail in the next couple of sections. However, you may see the different types of requests appear in your network log and, since it may have a performance impact on your application, it may benefit you to know why and when these requests are sent. As the developer, you don't normally need to care about this when you are constructing requests to be sent to a server. There are two types of CORS request: "simple" requests, and "preflight" requests, and it's the browser that determines which is used.

Or it can be narrowed down to a specific origin: Access -Control -Allow -Origin : https : / /example. For example, to allow access from any origin, you can set this header as follows: Access -Control -Allow -Origin : * This header specifies which origins can access the resource. There are a few headers that can be set, but the primary one that determines who can access a resource is Access -Control -Allow -Origin.

Web browsers can use these headers to determine whether or not an XMLHttpRequest call should continue or fail. Their presence can be used to determine that a request supports CORS. When a server has been configured correctly to allow cross-origin resource sharing, some special headers will be included.
