TIP #1: Use ngrok to tunnel your localhost port 80.
TIP #2: To get the client code, check this snippet or scroll all the way to the bottom.
- checkResource(req, res, next)
Check API resource and skip first middleware for specific resource
- specificCors(req, res, next)
Sets Specific CORS Reponse headers
- genCors(req, res, next)
Sets General CORS Response headers
Check API resource and skip first middleware for specific resource
Kind: global function
Param | Type | Description |
---|---|---|
req | * |
HTTP Request object |
res | * |
HTTP Response object |
next | * |
Method executes next middleware |
Sets Specific CORS Reponse headers
Kind: global function
Param | Type | Description |
---|---|---|
req | * |
HTTP Request object |
res | * |
HTTP Response object |
next | * |
Method executes next middleware |
Sets General CORS Response headers
Kind: global function
Param | Type | Description |
---|---|---|
req | * |
HTTP Request object |
res | * |
HTTP Response object |
next | * |
Method executes next middleware |
Put this in your HTML and you are good to go. Make sure you've a demo
element in your HTML code to render the contents.
<script>
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML = this.responseText;
}
};
xhttp.open("GET", "https://cdc-state-management.herokuapp.com/api/cookies", true);
/*If you are looking for cookies from cross-domain then xhttp.withCredentials is mandatory.
*/
xhttp.withCredentials = true;
xhttp.send();
}
</script>