CORS Request with Credentials [JavaScript/AJAX Code]

An example of sending a CORS request with an Origin header and an authorization cookie. In this CORS Request with Credentials example, the Origin is provided with "Origin: https://example.reqbin.com" request header, and the cookie is provided with the "Cookie: authCookie=my_auth_cookie" header. The JavaScript/AJAX code was automatically generated for the CORS Request Credentials example.
CORS Request with Credentials [JavaScript/AJAX Code] Send
GET /echo/get/json HTTP/1.1
Host: reqbin.com
Origin: https://example.reqbin.com
Cookie: authCookie=my_auth_cookie

Updated: Viewed: 7352 times
JavaScript/AJAX code for CORS Request Credentials example

JavaScript/AJAX code for CORS Request Credentials Example

This JavaScript/AJAX code snippet was generated automatically for the CORS Request Credentials example.
<< Back to the CORS Request Credentials example

CORS Requests

CORS is a mechanism that provides secure communication between browsers and servers running on different origins.

CORS allows a web application running on www.site1.com to securely access restricted resources on www.site2.com.

CORS is a way for the server to check if the request is coming from an allowed origin.

What is CORS?

Cross-Origin Resource Sharing (CORS) is an HTTP header-based mechanism that enables secure communication between browsers and servers running from different sources. These sources can differ from the current ones by hostname, HTTP scheme, or port number. A feature of CORS implementation was related to the restrictions of the single-origin policy, which restricts resources to interact only with resources located in the same domain. CORS is a way that a server can check if a request is coming from an allowed source and tell the browser not to block it. To make CORS requests using Curl, you need to provide an Origin header for your requests.

Curl CORS Example
curl -H "Origin: https://example.reqbin.com"

Generate code snippets for JavaScript/AJAX and other programming languages

Convert your CORS Request Credentials request to the PHP, JavaScript/AJAX, Curl/Bash, Python, Java, C#/.NET code snippets using the JavaScript/AJAX code generator.